Problem and weight pair for use in meta-optimization.
Пример #1
0
 /// <summary>
 /// Construct the object, weighted problems.
 /// </summary>
 /// <param name="optimizer">Optimize to be used.</param>
 /// <param name="weightedProblems">Array of weighted problems to be optimized.</param>
 /// <param name="numRuns">Number of optimization runs per problem.</param>
 public MetaFitness(Optimizer optimizer, WeightedProblem[] weightedProblems, int numRuns)
     : base()
 {
     Optimizer = optimizer;
     NumRuns = numRuns;
     ProblemIndex = new ProblemIndex(weightedProblems);
 }
Пример #2
0
        /// <summary>
        /// Construct the ProblemIndex-object.
        /// </summary>
        /// <param name="weightedProblems">The problems to be indexed.</param>
        public ProblemIndex(WeightedProblem[] weightedProblems)
            : base()
        {
            Index = new List<ProblemFitness>(weightedProblems.Count());

            double weightSum = weightedProblems.Sum(o => o.Weight);

            foreach (WeightedProblem weightedProblem in weightedProblems)
            {
                Problem problem = weightedProblem.Problem;
                double weight = weightedProblem.Weight;
                double weightNormalized = weight / weightSum;

                Debug.Assert(weight > 0);

                Index.Add(new ProblemFitness(problem, weightNormalized));
            }
        }
Пример #3
0
        /// <summary>
        /// Construct the ProblemIndex-object.
        /// </summary>
        /// <param name="weightedProblems">The problems to be indexed.</param>
        public ProblemIndex(WeightedProblem[] weightedProblems)
            : base()
        {
            // Ensure array has elements.
            Debug.Assert(weightedProblems.Length > 0);

            Index = new List<ProblemFitness>(weightedProblems.Length);

            double weightSum = weightedProblems.Sum(o => o.Weight);

            foreach (WeightedProblem weightedProblem in weightedProblems)
            {
                Problem problem = weightedProblem.Problem;
                double weight = weightedProblem.Weight;
                double weightNormalized = weight / weightSum;

                // Ensure weight is positive.
                Debug.Assert(weight > 0);

                Index.Add(new ProblemFitness(problem, weightNormalized));
            }
        }