Changeset 8006 for trunk/sources
- Timestamp:
- 06/14/12 10:46:19 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs
r7852 r8006 31 31 namespace HeuristicLab.Problems.VehicleRouting.Interfaces { 32 32 public interface IVRPProblemInstance: IItem { 33 IVRPEvaluator SolutionEvaluator { get; }33 IVRPEvaluator SolutionEvaluator { get; set; } 34 34 IVRPEvaluator MoveEvaluator { get; } 35 35 IEnumerable<IOperator> Operators { get; } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r7934 r8006 174 174 return evaluator; 175 175 } 176 177 set { 178 moveEvaluator = null; 179 evaluator = value; 180 EvalBestKnownSolution(); 181 } 176 182 } 177 183 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r7999 r8006 41 41 [Creatable("Problems")] 42 42 [StorableClass] 43 public sealed class VehicleRoutingProblem : P arameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> {43 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> { 44 44 public string Filename { get; set; } 45 45 … … 107 107 public ISolutionCreator SolutionCreator { 108 108 get { return SolutionCreatorParameter.Value; } 109 }110 111 [Storable]112 private List<IItem> operators;113 114 public IEnumerable<IItem> Operators {115 get { return operators; }116 109 } 117 110 #endregion … … 131 124 EvaluatorParameter.Hidden = true; 132 125 133 operators = new List<IItem>();134 135 126 InitializeRandomVRPInstance(); 136 127 InitializeOperators(); … … 147 138 private VehicleRoutingProblem(VehicleRoutingProblem original, Cloner cloner) 148 139 : base(original, cloner) { 149 this.operators = original.operators.Select(x => (IItem)cloner.Clone(x)).ToList();150 140 this.AttachEventHandlers(); 151 141 } … … 162 152 if (handler != null) handler(this, EventArgs.Empty); 163 153 } 164 public event EventHandler OperatorsChanged;165 private void OnOperatorsChanged() {166 EventHandler handler = OperatorsChanged;167 if (handler != null) handler(this, EventArgs.Empty);168 }169 public event EventHandler Reset;170 private void OnReset() {171 EventHandler handler = Reset;172 if (handler != null) handler(this, EventArgs.Empty);173 }174 154 #endregion 175 155 … … 181 161 } 182 162 163 [Storable(Name = "operators", AllowOneWay = true)] 164 private List<IOperator> StorableOperators { 165 set { Operators.AddRange(value); } 166 } 167 183 168 private void AttachEventHandlers() { 184 169 ProblemInstanceParameter.ValueChanged += new EventHandler(ProblemInstanceParameter_ValueChanged); 185 170 BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged); 171 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 172 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 186 173 } 187 174 … … 193 180 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator; 194 181 IVRPCreator defaultCreator = null; 195 foreach (IVRPCreator creator in operators.Where(o => o is IVRPCreator)) {182 foreach (IVRPCreator creator in Operators.Where(o => o is IVRPCreator)) { 196 183 solutionCreatorParameter.ValidValues.Add(creator); 197 184 if (creator is Encodings.Alba.RandomCreator) … … 220 207 221 208 void ProblemInstance_EvaluationChanged(object sender, EventArgs e) { 209 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator; 222 210 EvalBestKnownSolution(); 223 211 } … … 245 233 246 234 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 247 ParameterizeSolutionCreator();248 249 235 OnSolutionCreatorChanged(); 250 236 } 251 237 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 238 if (ProblemInstance != null) 239 ProblemInstance.SolutionEvaluator = EvaluatorParameter.Value; 252 240 OnEvaluatorChanged(); 253 241 } 254 242 255 243 private void InitializeOperators() { 256 operators = new List<IItem>();244 Operators.Clear(); 257 245 258 246 if (ProblemInstance != null) { 259 operators.AddRange(247 Operators.AddRange( 260 248 ProblemInstance.Operators.Concat( 261 249 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); … … 263 251 264 252 ParameterizeOperators(); 265 }266 267 private void ParameterizeSolutionCreator() {268 if (SolutionCreator is IMultiVRPOperator) {269 (SolutionCreator as IMultiVRPOperator).SetOperators(Operators.OfType<IOperator>());270 }271 253 } 272 254
Note: See TracChangeset
for help on using the changeset viewer.