コード例 #1
0
ファイル: PMOEAD.cs プロジェクト: bauer-martin/thor-avm
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="problem">Problem to solve</param>
        public PMOEAD(Problem problem)
            : base(problem)
        {
            parentThread = null;

            functionType = "_TCHE1";

            id = 0;
        }
コード例 #2
0
ファイル: PMOEAD.cs プロジェクト: bauer-martin/thor-avm
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentThread"></param>
        /// <param name="problem">Problem to solve</param>
        /// <param name="id"></param>
        /// <param name="numberOfThreads"></param>
        public PMOEAD(PMOEAD parentThread, Problem problem, int id, int numberOfThreads)
            : base(problem)
        {
            this.parentThread = parentThread;

            this.numberOfThreads = numberOfThreads;
            tasks = new Task[numberOfThreads];

            functionType = "_TCHE1";

            this.id = id;
        }
コード例 #3
0
ファイル: PMOEAD.cs プロジェクト: bauer-martin/thor-avm
 private void CreateTask(Task[] tasks, PMOEAD parent, Core.Problem Problem, int j, int numberOfThreads)
 {
     tasks[j] = new Task(() => new PMOEAD(parent, Problem, j, numberOfThreads).Run());
 }
コード例 #4
0
ファイル: PMOEAD.cs プロジェクト: bauer-martin/thor-avm
        public override SolutionSet Execute()
        {
            parentThread = this;

            evaluations = 0;
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations);
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize);
            JMetalCSharp.Utils.Utils.GetStringValueFromParameter(this.InputParameters, "dataDirectory", ref dataDirectory);
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "numberOfThreads", ref numberOfThreads);

            tasks = new Task[numberOfThreads];

            barrier = new Barrier(numberOfThreads);

            population = new SolutionSet(populationSize);
            indArray   = new Solution[Problem.NumberOfObjectives];

            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "T", ref t);
            JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "nr", ref nr);
            JMetalCSharp.Utils.Utils.GetDoubleValueFromParameter(this.InputParameters, "delta", ref delta);

            neighborhood = new int[populationSize][];
            for (int i = 0; i < populationSize; i++)
            {
                neighborhood[i] = new int[t];
            }

            z = new double[Problem.NumberOfObjectives];

            lambda = new double[populationSize][];
            for (int i = 0; i < populationSize; i++)
            {
                lambda[i] = new double[Problem.NumberOfObjectives];
            }

            crossover = Operators["crossover"];            // default: DE crossover
            mutation  = Operators["mutation"];             // default: polynomial mutation

            // STEP 1. Initialization
            // STEP 1.1. Compute euclidean distances between weight vectors and find T
            InitUniformWeight();

            InitNeighborhood();

            // STEP 1.2. Initialize population
            InitPopulation();

            // STEP 1.3. Initialize z
            InitIdealPoint();

            initTime = Environment.TickCount;

            for (int j = 0; j < numberOfThreads; j++)
            {
                CreateTask(tasks, this, Problem, j, numberOfThreads);
                tasks[j].Start();
            }

            for (int i = 0; i < numberOfThreads; i++)
            {
                try
                {
                    tasks[i].Wait();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error in " + this.GetType().FullName + ".Execute()");
                    Logger.Log.Error(this.GetType().FullName + ".Execute()", ex);
                }
            }

            Result = population;

            return(population);
        }