using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EvoBoat.EvoAlg.Perm
{
    /// <summary>
    /// Permutation optimization problem
    /// </summary>
    public abstract class PermProblem<S> : IProblem<S, PermVector>
        where S : ISolution<PermVector>
    {
        protected int dimension;
        public int Dimension { get { return dimension; } }

        public PermProblem(int n)
        {
            this.dimension = n;
        }

        public abstract double Evaluate(PermVector p);
        public virtual double Evaluate(S sol)
        {
            sol.Fit = Evaluate(sol.Content);
            return sol.Fit;
        }

        public virtual bool IsFeasible(PermVector p)
        {
            return PermVector.IsPerm(p.values);
        }
    }
}
