Changeset 11187
- Timestamp:
- 07/14/14 13:21:16 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/Evaluators/OrienteeringEvaluator.cs
r11186 r11187 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 26 using HeuristicLab.Operators; 26 27 using HeuristicLab.Parameters; … … 31 32 public ILookupParameter<DoubleValue> QualityParameter { 32 33 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 34 } 35 public ILookupParameter<IntegerVector> SolutionParameter { 36 get { return (ILookupParameter<IntegerVector>)Parameters["Solution"]; } 37 } 38 public ILookupParameter<DoubleArray> ScoresParameter { 39 get { return (ILookupParameter<DoubleArray>)Parameters["Scores"]; } 33 40 } 34 41 … … 46 53 : base() { 47 54 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the Orienteering solution.")); 48 // TODO 55 Parameters.Add(new LookupParameter<IntegerVector>("Solution", "The Orienteering Solution given in path representation.")); 56 Parameters.Add(new LookupParameter<DoubleArray>("Scores", "The scores of the points.")); 49 57 } 50 58 51 public structOrienteeringEvaluation {59 public class OrienteeringEvaluation { 52 60 public DoubleValue Quality; 53 61 } 54 62 55 public static OrienteeringEvaluation Apply() { 56 // TODO 57 return default(OrienteeringEvaluation); 63 public static OrienteeringEvaluation Apply(IntegerVector solution, DoubleArray scores) { 64 // TODO distance penalty 65 double score = 0.0; 66 67 for (int i = 0; i < solution.Length; i++) { 68 score += scores[i]; 69 } 70 71 return new OrienteeringEvaluation { 72 Quality = new DoubleValue(score) 73 }; 58 74 } 59 75 60 76 public override IOperation InstrumentedApply() { 61 // TODO 62 var evaluation = Apply(); 77 var evaluation = Apply(SolutionParameter.ActualValue, ScoresParameter.ActualValue); 78 79 QualityParameter.ActualValue = evaluation.Quality; 63 80 64 81 return base.InstrumentedApply(); -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/HeuristicLab.Problems.Orienteering-3.3.csproj
r11186 r11187 46 46 </ItemGroup> 47 47 <ItemGroup> 48 <Compile Include="DistanceMatrix.cs" /> 48 49 <Compile Include="Interfaces\IOrienteeringEvaluator.cs" /> 49 50 <Compile Include="Evaluators\OrienteeringEvaluator.cs" /> -
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r11186 r11187 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Encodings.IntegerVectorEncoding; 26 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 27 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 30 … … 38 40 public string Filename { get; set; } 39 41 42 #region Parameter Properties 43 public OptionalValueParameter<DoubleMatrix> CoordinatesParameter { 44 get { return (OptionalValueParameter<DoubleMatrix>)Parameters["Coordinates"]; } 45 } 46 public OptionalValueParameter<DistanceMatrix> DistanceMatrixParameter { 47 get { return (OptionalValueParameter<DistanceMatrix>)Parameters["DistanceMatrix"]; } 48 } 49 public ValueParameter<BoolValue> UseDistanceMatrixParameter { 50 get { return (ValueParameter<BoolValue>)Parameters["UseDistanceMatrix"]; } 51 } 52 53 public ValueParameter<IntValue> StartingPointParameter { 54 get { return (ValueParameter<IntValue>)Parameters["StartingPoint"]; } 55 } 56 public ValueParameter<IntValue> TerminusPointParameter { 57 get { return (ValueParameter<IntValue>)Parameters["TerminusPoint"]; } 58 } 59 public ValueParameter<DoubleValue> MaximumDistanceParameter { 60 get { return (ValueParameter<DoubleValue>)Parameters["MaximumDistance"]; } 61 } 62 public ValueParameter<DoubleArray> ScoresParameter { 63 get { return (ValueParameter<DoubleArray>)Parameters["Scores"]; } 64 } 65 public ValueParameter<DoubleValue> FixedPenaltyParameter { 66 get { return (ValueParameter<DoubleValue>)Parameters["FixedPenalty"]; } 67 } 68 69 public OptionalValueParameter<IntegerVector> BestKnownSolutionParameter { 70 get { return (OptionalValueParameter<IntegerVector>)Parameters["BestKnownSolution"]; } 71 } 72 #endregion 73 74 #region Properties 75 public DoubleMatrix Coordinates { 76 get { return CoordinatesParameter.Value; } 77 set { CoordinatesParameter.Value = value; } 78 } 79 public DistanceMatrix DistanceMatrix { 80 get { return DistanceMatrixParameter.Value; } 81 set { DistanceMatrixParameter.Value = value; } 82 } 83 public BoolValue UseDistanceMatrix { 84 get { return UseDistanceMatrixParameter.Value; } 85 set { UseDistanceMatrixParameter.Value = value; } 86 } 87 public DoubleValue MaximumDistance { 88 get { return MaximumDistanceParameter.Value; } 89 set { MaximumDistanceParameter.Value = value; } 90 } 91 public DoubleArray Scores { 92 get { return ScoresParameter.Value; } 93 set { ScoresParameter.Value = value; } 94 } 95 public IntegerVector BestKnownSolution { 96 get { return BestKnownSolutionParameter.Value; } 97 set { BestKnownSolutionParameter.Value = value; } 98 } 99 #endregion 100 40 101 [StorableConstructor] 41 102 private OrienteeringProblem(bool deserializing) … … 55 116 public OrienteeringProblem() 56 117 : base(new OrienteeringEvaluator(), new UniformRandomIntegerVectorCreator()) { 57 // TODO: Parameters 118 Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the points.")); 119 Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the points.")); 120 Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if the coordinates based evaluators should calculate the distance matrix from the coordinates and use it for evaluation similar to the distance matrix evaluator, otherwise false.", new BoolValue(true))); 121 Parameters.Add(new ValueParameter<IntValue>("StartingPoint", "Index of the starting point.", new IntValue(0))); 122 Parameters.Add(new ValueParameter<IntValue>("TerminusPoint", "Index of the ending point.", new IntValue(0))); 123 Parameters.Add(new ValueParameter<DoubleValue>("MaximumDistance", "The maximum distance constraint for a Orienteering solution.")); 124 Parameters.Add(new ValueParameter<DoubleArray>("Scores", "The scores of the points.", new DoubleArray())); 125 Parameters.Add(new ValueParameter<DoubleValue>("FixedPenalty", "The penalty for each visited vertex.")); 126 Parameters.Add(new OptionalValueParameter<IntegerVector>("BestKnownSolution", "The best known solution of this Orienteering instance.")); 58 127 59 128 Maximization.Value = true; … … 71 140 } 72 141 73 #region events142 #region Events 74 143 protected override void OnSolutionCreatorChanged() { 75 144 base.OnSolutionCreatorChanged(); … … 100 169 private void RegisterEventHandlers() { 101 170 SolutionCreator.IntegerVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged); 171 // TODO 102 172 } 103 173 private void ParameterizeSolutionCreator() { 104 // TODO 174 if (SolutionCreator.LengthParameter.Value == null 175 || SolutionCreator.LengthParameter.Value.Value != Scores.Length) { 176 SolutionCreator.LengthParameter.Value = new IntValue(Scores.Length); 177 } 105 178 } 106 179 private void ParameterizeEvaluator() { … … 111 184 } 112 185 private void ParameterizeAnalyzer() { 113 // TODO 186 // TODO 114 187 } 115 188 private void InitializeOperators() {
Note: See TracChangeset
for help on using the changeset viewer.