Changeset 11786
- Timestamp:
- 01/16/15 11:14:50 (10 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/MultiObjectiveProgrammableProblem.cs
r11780 r11786 21 21 22 22 using System.Linq; 23 using HeuristicLab.Analysis;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; … … 43 42 protected MultiObjectiveProgrammableProblem() 44 43 : base() { 45 Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", new BoolArray(Maximization)));44 Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", new BoolArray())); 46 45 47 46 Operators.Add(Evaluator); 48 Operators.Add(new BestScopeSolutionAnalyzer());49 47 Operators.Add(new MultiObjectiveAnalyzer()); 50 48 … … 61 59 public virtual void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) { } 62 60 61 protected override void OnEncodingChanged() { 62 base.OnEncodingChanged(); 63 Parameters["Maximization"].ActualValue = new BoolArray(Maximization); 64 } 63 65 64 66 protected override void OnEvaluatorChanged() { … … 67 69 } 68 70 69 protected override void ParameterizeOperators() { 70 base.ParameterizeOperators(); 71 private void ParameterizeOperators() { 71 72 foreach (var op in Operators.OfType<IMultiObjectiveEvaluationOperator>()) 72 73 op.EvaluateFunc = Evaluate; -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/ProgrammableProblem.cs
r11753 r11786 42 42 } 43 43 44 //mkommend necessary for reuse of operators if the encoding changes 45 private TEncoding oldEncoding; 46 44 47 IEncoding IProblemDefinition.Encoding { get { return Encoding; } } 45 48 public TEncoding Encoding { … … 49 52 EncodingParameter.Value = value; 50 53 } 51 }52 //mkommend necessary for reuse of operators if the encoding changes53 private TEncoding oldEncoding;54 55 public virtual IEnumerable<Individual> GetNeighbors(Individual individual, IRandom random) {56 return Enumerable.Empty<Individual>();57 54 } 58 55 … … 97 94 oldEncoding = Encoding; 98 95 96 foreach (var op in Operators.OfType<IEncodingOperator>()) 97 op.EncodingParameter.ActualName = EncodingParameter.Name; 98 99 99 var solutionCreatorType = Encoding.GetType().BaseType.GetGenericArguments(); 100 100 var paramType = typeof(ValueParameter<>).MakeGenericType(solutionCreatorType); … … 111 111 base.OnSolutionCreatorChanged(); 112 112 Encoding.SolutionCreator = SolutionCreator; 113 }114 115 116 protected virtual void ParameterizeOperators() {117 foreach (var op in Operators.OfType<IEncodingOperator>())118 op.EncodingParameter.ActualName = EncodingParameter.Name;119 foreach (var op in Operators.OfType<INeighborBasedOperator>())120 op.GetNeighborsFunc = GetNeighbors;121 113 } 122 114 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/Scripts/Templates/CompiledMultiObjectiveProblemDefinition.cs
r11767 r11786 31 31 var qualities = new[] { 0.0, 0.0 }; 32 32 // use vars.yourVariable to access variables in the variable store i.e. yourVariable 33 // qualities = new [] { individual.RealVector(" "r"").Sum(x => x * x), individual.RealVector(""r"").Sum(x => x * x * x) };33 // qualities = new [] { individual.RealVector("r").Sum(x => x * x), individual.RealVector("r").Sum(x => x * x * x) }; 34 34 return qualities; 35 35 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/New/SingleObjectiveProgrammableProblem.cs
r11780 r11786 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using HeuristicLab.Analysis; … … 44 45 protected SingleObjectiveProgrammableProblem() 45 46 : base() { 46 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", new BoolValue( Maximization)));47 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", new BoolValue())); 47 48 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem.")); 48 49 … … 66 67 public abstract double Evaluate(Individual individual, IRandom random); 67 68 public virtual void Analyze(Individual[] individuals, double[] qualities, ResultCollection results) { } 69 public virtual IEnumerable<Individual> GetNeighbors(Individual individual, IRandom random) { 70 return Enumerable.Empty<Individual>(); 71 } 68 72 73 74 protected override void OnEncodingChanged() { 75 base.OnEncodingChanged(); 76 var max = (BoolValue)Parameters["Maximization"].ActualValue; 77 max.Value = Maximization; 78 } 69 79 70 80 protected override void OnEvaluatorChanged() { … … 73 83 } 74 84 75 protected override void ParameterizeOperators() { 76 base.ParameterizeOperators(); 85 private void ParameterizeOperators() { 77 86 foreach (var op in Operators.OfType<ISingleObjectiveEvaluationOperator>()) 78 87 op.EvaluateFunc = Evaluate; 79 88 foreach (var op in Operators.OfType<ISingleObjectiveAnalysisOperator>()) 80 89 op.AnalyzeAction = Analyze; 90 foreach (var op in Operators.OfType<INeighborBasedOperator>()) 91 op.GetNeighborsFunc = GetNeighbors; 81 92 } 82 93
Note: See TracChangeset
for help on using the changeset viewer.