Esempio n. 1
0
        private void DisplayParetoFront <S>(NondominatedPopulation <S> archive)
            where S : ContinuousVector, new()
        {
            GraphPane pane = chtParetoFront.GraphPane;

            pane.XAxis.Title.Text = "Objective 1";
            pane.YAxis.Title.Text = "Objective 2";
            pane.Title.Text       = string.Format("Problem: {0}", (ProblemType)cboProblem.SelectedItem);

            PointPairList list = new PointPairList();

            foreach (S s in archive.Solutions)
            {
                list.Add(s.FindObjectiveAt(0), s.FindObjectiveAt(1));
            }

            AlgorithmType algorithm_type = (AlgorithmType)cboAlgorithm.SelectedItem;
            LineItem      myCurve        = pane.AddCurve(string.Format("{0} ({1})", algorithm_type.ToString(), cboProblem.SelectedItem), list, GetParetoFrontColor());

            myCurve.Symbol.Type    = ZedGraph.SymbolType.Plus;
            myCurve.Line.IsVisible = false;

            pane.AxisChange();
            chtParetoFront.Invalidate();

            DataTable table = new DataTable();

            table.Columns.Add("#");
            IMOOProblem problem = archive[0].Problem;

            for (int i = 0; i < problem.GetObjectiveCount(); ++i)
            {
                table.Columns.Add(string.Format("Objective {0}", i + 1));
            }
            for (int i = 0; i < problem.GetDimensionCount(); ++i)
            {
                table.Columns.Add(string.Format("x[{0}]", i));
            }

            for (int i = 0; i < archive.Count; ++i)
            {
                S             s      = archive[i];
                List <object> values = new List <object>();
                values.Add(i + 1);
                for (int j = 0; j < problem.GetObjectiveCount(); ++j)
                {
                    values.Add(s.FindObjectiveAt(j));
                }
                for (int j = 0; j < problem.GetDimensionCount(); ++j)
                {
                    values.Add(s[j]);
                }
                table.Rows.Add(values.ToArray());
            }

            dgvParetoFront.DataSource = table;
        }
Esempio n. 2
0
        public virtual void Evaluate()
        {
            int objective_count = mProblem.GetObjectiveCount();

            while (mObjectives.Count < objective_count)
            {
                mObjectives.Add(0);
            }
            for (int objective_index = 0; objective_index < objective_count; ++objective_index)
            {
                int sign = mProblem.IsMaximizing() ? (-1) : 1;
                mObjectives[objective_index] = sign * mProblem.CalcObjective(this, objective_index);
            }
        }
Esempio n. 3
0
        public override void Initialize()
        {
            if (mIsInitialized)
            {
                return;
            }
            mIsInitialized = true;

            int dimension_count = mProblem.GetDimensionCount();

            for (int objective_index = 0; objective_index != dimension_count; objective_index++)
            {
                mEliteDesignVariables[objective_index] = mProblem.GetLowerBound(objective_index) + DistributionModel.GetUniform() * (mProblem.GetUpperBound(objective_index) - mProblem.GetLowerBound(objective_index));
            }

            int objective_count = mProblem.GetObjectiveCount();
            int design_variable_count_per_objective = dimension_count / objective_count;

            //Initialize the NashNodes
            for (int objective_index = 0; objective_index < objective_count; objective_index++)
            {
                Dictionary <int, double> ellite_design_variables       = new Dictionary <int, double>();
                Dictionary <int, int>    design_variable_local_mapping = new Dictionary <int, int>();
                int starting_design_variable_index = objective_index * design_variable_count_per_objective;
                int ending_design_variable_index   = (objective_index + 1) * design_variable_count_per_objective;
                for (int j = 0; j < dimension_count; ++j)
                {
                    if (j >= starting_design_variable_index && j < ending_design_variable_index)
                    {
                        design_variable_local_mapping[j] = j - starting_design_variable_index;
                    }
                    else
                    {
                        ellite_design_variables[j] = mEliteDesignVariables[j];
                    }
                }
                NashNode <S> nash_node = new NashNode <S>(mProblem, mConfig, ellite_design_variables, design_variable_local_mapping, objective_index);
                mNashNodes.Add(nash_node);
                mNashNodes[objective_index].Initialize();
            }

            //Initialize the ParetoNode and Fixed Array
            mParetoNode = new ParetoNode <S>(mProblem);
            mParetoNode.Population.Config.Copy(mConfig);
            mParetoNode.Initialize();
        }