using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EvoBoat.EvoAlg.WWO;

namespace EvoBoat.EvoAlg.Perm
{
    public class Perm_NWWOAlg<P,S> : COMB_NWWOAlg<P, S, PermVector, int>
        where P : PermProblem<S>
        where S : VecSolution<PermVector, int>, new()
    {
        public Perm_NWWOAlg() : base()
        { }

        public Perm_NWWOAlg(P problem, int seed = 0) : base(problem, seed)
        {
            this.Factory = new PermSolutionFactory<P, S>(problem);
        }

        public override void SetFactory()
        {
            if (Problem == null)
                throw new ArgumentNullException("Please assign the problem instance before set the factory");
            Factory = new PermSolutionFactory<P, S>(Problem);
        }

        public override double MoveP(S sol, int index, int d)
        {
            if (d < Problem.Dimension)
            {
                int d1 = Rand.Next(d, Problem.Dimension);
                sol.Content.Reverse(d, d1);
            }
            return 0;
        }

        public override double MoveB(S sol, int index, int d)
        {
            int d1 = RandomSelectIndex(Problem.Dimension, d);
            sol.Content.Swap(d, d1);
            return 0;
        }
    }
}
