Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/04/17 12:37:52 (8 years ago)
Author:
bwerth
Message:

#2745 added several new InfillCriteria and moved Parameters from the InfillProblem to the Criteria themselves; added Sanitiy checks for GaussianProcessRegression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/EfficientGlobalOptimization/HeuristicLab.Algorithms.EGO/Problems/InfillProblem.cs

    r14768 r14818  
    2727using HeuristicLab.Optimization;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Problems.DataAnalysis;
    3029
    3130namespace HeuristicLab.Algorithms.EGO {
     
    3433  public sealed class InfillProblem : SingleObjectiveBasicProblem<RealVectorEncoding> {
    3534
    36     public override bool Maximization => true;
     35    public override bool Maximization => true;  //This is necessary because algorithms do not expect the maximization to change
    3736
    3837    #region Properties;
     
    4140    [Storable]
    4241    private SingleObjectiveBasicProblem<IEncoding> problem;
    43     [Storable]
    44     private IRegressionSolution regressionSolution;
    45 
    4642
    4743    public IInfillCriterion InfillCriterion
     
    5753        problem = value;
    5854        if (problem == null) return;
    59         Encoding = problem.Encoding as RealVectorEncoding;
     55        var enc = problem.Encoding as RealVectorEncoding;
     56        if (enc == null) throw new ArgumentException("EGO can not be performed on non-RealVectorEncodings");
     57        Encoding = enc;
    6058        SolutionCreator = new UniformRandomRealVectorCreator();//ignore Problem specific Solution Creation
    61         if (Encoding == null) throw new ArgumentException("EGO can not be performed on non-RealVectorEncodings");
     59
    6260      }
    63     }
    64     public IRegressionSolution RegressionSolution
    65     {
    66       get { return regressionSolution; }
    67       set { regressionSolution = value; }
    6861    }
    6962    #endregion
     
    7568      infillCriterion = cloner.Clone(original.InfillCriterion);
    7669      problem = cloner.Clone(original.Problem);
    77       regressionSolution = cloner.Clone(original.regressionSolution);
    7870    }
    7971    public InfillProblem() { }
     
    8274
    8375    public override double Evaluate(Individual individual, IRandom r) {
    84       var q = InfillCriterion.Evaluate(RegressionSolution, individual.RealVector(), Problem.Maximization);
    85       return InfillCriterion.Maximization(Problem.Maximization) ? q : -q; //This is necessary because Maximization is not supposed to change on a normal problem
     76      var q = InfillCriterion.Evaluate(individual.RealVector());
     77      return InfillCriterion.Maximization() ? q : -q;
    8678    }
    8779    public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    8880      base.Analyze(individuals, qualities, results, random);
    8981      var best = qualities.ArgMax(x => x);
    90       var qnew = InfillCriterion.Maximization(Problem.Maximization) ? qualities[best] : -qualities[best];
    91       //var best = Maximization ? qualities.ArgMax(x => x) : qualities.ArgMin(x => x);
     82      var qnew = InfillCriterion.Maximization() ? qualities[best] : -qualities[best];
    9283      const string qname = EfficientGlobalOptimizationAlgorithm.BestInfillQualityResultName;
    9384      const string sname = EfficientGlobalOptimizationAlgorithm.BestInfillSolutionResultName;
     
    9990      var qold = results[qname].Value as DoubleValue;
    10091      if (qold == null) throw new ArgumentException("Old best quality is not a double value. Conflicting Analyzers?");
    101       if (qold.Value >= qnew == InfillCriterion.Maximization(Problem.Maximization)) return;
     92      if (qold.Value >= qnew == InfillCriterion.Maximization()) return;
    10293      results[sname].Value = (RealVector)individuals[best].RealVector().Clone();
    10394      qold.Value = qnew;
    104 
    10595    }
    10696  }
Note: See TracChangeset for help on using the changeset viewer.