Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/29/14 17:39:19 (10 years ago)
Author:
abeham
Message:

#2174: Made single-objective programmable problem compatible with scatter search

Location:
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Helper.cs

    r11396 r11405  
    6464        permutations: permDict.Count > 0 ? permDict : null);
    6565    }
     66
     67    internal static void Write(IScope scope, ParameterVector vector) {
     68      foreach (var param in vector.BinaryNames) {
     69        if (scope.Variables.ContainsKey(param))
     70          scope.Variables[param].Value = vector.BinaryVector(param);
     71        else scope.Variables.Add(new Variable(param, vector.BinaryVector(param)));
     72      }
     73      foreach (var param in vector.IntegerNames) {
     74        if (scope.Variables.ContainsKey(param))
     75          scope.Variables[param].Value = vector.IntegerVector(param);
     76        else scope.Variables.Add(new Variable(param, vector.IntegerVector(param)));
     77      }
     78      foreach (var param in vector.RealNames) {
     79        if (scope.Variables.ContainsKey(param))
     80          scope.Variables[param].Value = vector.RealVector(param);
     81        else scope.Variables.Add(new Variable(param, vector.RealVector(param)));
     82      }
     83      foreach (var param in vector.PermutationNames) {
     84        if (scope.Variables.ContainsKey(param))
     85          scope.Variables[param].Value = vector.Permutation(param);
     86        else scope.Variables.Add(new Variable(param, vector.Permutation(param)));
     87      }
     88    }
    6689  }
    6790}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj

    r11400 r11405  
    159159    <Compile Include="Interfaces\IProblemDefinition.cs" />
    160160    <Compile Include="Interfaces\ISingleObjectiveProblemDefinition.cs" />
     161    <Compile Include="Operators\SingleObjectiveParameterVectorImprover.cs" />
    161162    <Compile Include="ProblemDefinition.cs" />
    162163    <Compile Include="ProblemDefinitionScript.cs" />
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveAnalyzer.cs

    r11396 r11405  
    4949    public override IOperation Apply() {
    5050      var host = ProblemDefinitionParameter.ActualValue;
    51       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
     51      if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    5252      var config = ConfigurationParameter.ActualValue;
    5353      var results = ResultsParameter.ActualValue;
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/SingleObjectiveEvaluator.cs

    r11396 r11405  
    6767      var random = RandomParameter.ActualValue;
    6868      var host = ProblemDefinitionParameter.ActualValue;
    69       if (host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");
     69      if (host.Instance == null) throw new InvalidOperationException("Problem definition is not available.");
    7070      var config = ConfigurationParameter.ActualValue;
    7171      var vector = Helper.Extract(ExecutionContext.Scope, config);
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r11399 r11405  
    171171        UpdateMultiVectorEncodingOperators(solutionCreators, configuration);
    172172      }
     173      UpdateImprovementOperators();
    173174      UpdateMoveOperators();
    174175    }
     
    852853    }
    853854
     855    protected virtual void UpdateImprovementOperators() {
     856      if (!Operators.Any(x => x is SingleObjectiveParameterVectorImprover))
     857        Operators.Add(new SingleObjectiveParameterVectorImprover());
     858      foreach (var improver in Operators.OfType<SingleObjectiveParameterVectorImprover>()) {
     859        improver.ConfigurationParameter.ActualName = ConfigurationParameter.Name;
     860        improver.MaximizationParameter.ActualName = MaximizationParameter.Name;
     861        improver.ProblemDefinitionParameter.ActualName = ProblemDefinitionParameter.Name;
     862        improver.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     863      }
     864    }
     865
    854866    protected virtual void UpdateMoveOperators() {
    855867      Operators.RemoveAll(x => x is IParameterVectorMoveOperator);
Note: See TracChangeset for help on using the changeset viewer.