Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/11 01:30:44 (14 years ago)
Author:
cneumuel
Message:

#1215

  • made all IAlgorithm types compatible to be loaded into MetaOptimization.
  • valid problem types are now automatically set
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/AlgorithmExecutor.cs

    r5281 r5337  
    1111  /// </summary>
    1212  public class AlgorithmExecutor {
    13     private EngineAlgorithm algorithm;
     13    private IAlgorithm algorithm;
    1414    private AutoResetEvent waitHandle = new AutoResetEvent(false);
    1515
    16     public AlgorithmExecutor(EngineAlgorithm algorithm) {
     16    public AlgorithmExecutor(IAlgorithm algorithm) {
    1717      this.algorithm = algorithm;
    1818    }
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/ParameterConfigurationEvaluator.cs

    r5313 r5337  
    3030      get { return (ILookupParameter<TypeValue>)Parameters[MetaOptimizationProblem.AlgorithmTypeParameterName]; }
    3131    }
    32     public ILookupParameter<IItemList<ISingleObjectiveProblem>> ProblemsParameter {
    33       get { return (ILookupParameter<IItemList<ISingleObjectiveProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }
     32    public ILookupParameter<IItemList<IProblem>> ProblemsParameter {
     33      get { return (ILookupParameter<IItemList<IProblem>>)Parameters[MetaOptimizationProblem.ProblemsParameterName]; }
    3434    }
    3535    public ILookupParameter<ParameterConfigurationTree> ParameterConfigurationParameter {
     
    5858      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the ParameterVector."));
    5959      Parameters.Add(new LookupParameter<TypeValue>(MetaOptimizationProblem.AlgorithmTypeParameterName, "Missing description."));
    60       Parameters.Add(new LookupParameter<IItemList<ISingleObjectiveProblem>>(MetaOptimizationProblem.ProblemsParameterName, "Missing description."));
     60      Parameters.Add(new LookupParameter<IItemList<IProblem>>(MetaOptimizationProblem.ProblemsParameterName, "Missing description."));
    6161      Parameters.Add(new LookupParameter<ParameterConfigurationTree>("ParameterConfigurationTree", "Missing description."));
    6262      Parameters.Add(new LookupParameter<IntValue>(MetaOptimizationProblem.RepetitionsParameterName, "Number of evaluations on one problem."));
     
    7777    public override IOperation Apply() {
    7878      ParameterConfigurationTree parameterConfiguration = ParameterConfigurationParameter.ActualValue;
    79       EngineAlgorithm algorithm = (EngineAlgorithm)Activator.CreateInstance(AlgorithmTypeParameter.ActualValue.Value);
    80       IItemList<ISingleObjectiveProblem> problems = ProblemsParameter.ActualValue;
     79      IAlgorithm algorithm = (IAlgorithm)Activator.CreateInstance(AlgorithmTypeParameter.ActualValue.Value);
     80      IItemList<IProblem> problems = ProblemsParameter.ActualValue;
    8181      ItemDictionary<StringValue, RunCollection> runsCache = ResultsParameter.ActualValue.ContainsKey("Runs") ? (ItemDictionary<StringValue, RunCollection>)ResultsParameter.ActualValue["Runs"].Value : null;
    8282      double[] referenceQualities = GetReferenceQualities(problems);
     
    113113    }
    114114
    115     private double[] GetReferenceQualities(IItemList<ISingleObjectiveProblem> problems) {
     115    private double[] GetReferenceQualities(IItemList<IProblem> problems) {
    116116      double[] referenceQualities;
    117117      if (ProblemQualityReferencesParameter.ActualValue == null) {
     
    127127    }
    128128
    129     private RunCollection ExecuteAlgorithm(ParameterConfigurationTree parameterConfiguration, EngineAlgorithm algorithm, IItemList<ISingleObjectiveProblem> problems) {
    130       EngineAlgorithm algorithmClone = (EngineAlgorithm)algorithm.Clone();
     129    private RunCollection ExecuteAlgorithm(ParameterConfigurationTree parameterConfiguration, IAlgorithm algorithm, IItemList<IProblem> problems) {
     130      IAlgorithm algorithmClone = (IAlgorithm)algorithm.Clone();
    131131
    132132      // set parameters
     
    134134      algorithmClone.StoreAlgorithmInEachRun = false;
    135135
    136       algorithmClone.Engine = new SequentialEngine.SequentialEngine();
     136      if (algorithmClone is EngineAlgorithm) {
     137        ((EngineAlgorithm)algorithmClone).Engine = new SequentialEngine.SequentialEngine();
     138      }
    137139      algorithmClone.Prepare(true);
    138140
    139       foreach (ISingleObjectiveProblem problem in problems) {
     141      foreach (IProblem problem in problems) {
    140142        algorithmClone.Problem = (IProblem)problem.Clone();
    141143
Note: See TracChangeset for help on using the changeset viewer.