Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/10 11:37:00 (14 years ago)
Author:
svonolfe
Message:

Added move operators (WIP) (#1177)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings
Files:
29 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveEvaluator.cs

    r4369 r4370  
    3535    }
    3636
     37    public override ILookupParameter VRPMoveParameter {
     38      get { return TranslocationMoveParameter; }
     39    }
     40
    3741    [StorableConstructor]
    3842    private AlbaTranslocationMoveEvaluator(bool deserializing) : base(deserializing) { }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs

    r4369 r4370  
    5656    }
    5757
     58    public override ILookupParameter VRPMoveParameter {
     59      get { return TranslocationMoveParameter; }
     60    }
     61
    5862    public ILookupParameter<Permutation> PermutationParameter {
    5963      get {
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveMaker.cs

    r4369 r4370  
    3737    }
    3838
     39    public override ILookupParameter VRPMoveParameter {
     40      get { return TranslocationMoveParameter; }
     41    }
     42
    3943    public ILookupParameter<Permutation> PermutationParameter {
    4044      get { return moveMaker.PermutationParameter; }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveMaker.cs

    r4369 r4370  
    5555    private void UpdateMoveEvaluation() {
    5656      IVRPEvaluator evaluator = ProblemInstance.EvaluatorParameter.Value;
    57       foreach (IParameter parameter in evaluator.Parameters) {
    58         if (parameter is ILookupParameter
    59           && parameter != evaluator.VRPToursParameter
    60           && parameter != evaluator.ProblemInstanceParameter) {
    61           ILookupParameter evaluatorParameter = parameter as ILookupParameter;
     57      ICollection<IParameter> addedParameters = new List<IParameter>();
     58     
     59      try {
     60        foreach (IParameter parameter in evaluator.Parameters) {
     61          if (parameter is ILookupParameter
     62            && parameter != evaluator.VRPToursParameter
     63            && parameter != evaluator.ProblemInstanceParameter) {
     64            ILookupParameter evaluatorParameter = parameter as ILookupParameter;
    6265         
    63           string resultName = evaluatorParameter.ActualName;
    64           if (!this.Parameters.Exists(p => p.Name == resultName)) {
    65             ILookupParameter resultParameter = new LookupParameter<IItem>(resultName);
    66             resultParameter.ExecutionContext = ExecutionContext;
    67             this.Parameters.Add(resultParameter);
     66            string resultName = evaluatorParameter.ActualName;
     67            if (!this.Parameters.Exists(p => p.Name == resultName)) {
     68              ILookupParameter resultParameter = new LookupParameter<IItem>(resultName);
     69              resultParameter.ExecutionContext = ExecutionContext;
     70              this.Parameters.Add(resultParameter);
     71              addedParameters.Add(resultParameter);
     72            }
     73
     74            string moveResultName = VRPMoveEvaluator.MovePrefix + resultName;
     75            if (!this.Parameters.Exists(p => p.Name == moveResultName)) {
     76              ILookupParameter moveResultParameter = new LookupParameter<IItem>(moveResultName);
     77              moveResultParameter.ExecutionContext = ExecutionContext;
     78              this.Parameters.Add(moveResultParameter);
     79              addedParameters.Add(moveResultParameter);
     80            }
     81
     82            ILookupParameter result = Parameters[resultName] as ILookupParameter;
     83            ILookupParameter moveResult = Parameters[moveResultName] as ILookupParameter;
     84            result.ActualValue = moveResult.ActualValue.Clone() as IItem;
    6885          }
    69 
    70           string moveResultName = VRPMoveEvaluator.MovePrefix + resultName;
    71           if (!this.Parameters.Exists(p => p.Name == moveResultName)) {
    72             ILookupParameter moveResultParameter = new LookupParameter<IItem>(moveResultName);
    73             moveResultParameter.ExecutionContext = ExecutionContext;
    74             this.Parameters.Add(moveResultParameter);
    75           }
    76 
    77           ILookupParameter result = Parameters[resultName] as ILookupParameter;
    78           ILookupParameter moveResult = Parameters[moveResultName] as ILookupParameter;
    79           result.ActualValue = moveResult.ActualValue.Clone() as IItem;
     86        }
     87      }
     88      finally {
     89        foreach(IParameter parameter in addedParameters) {
     90          this.Parameters.Remove(parameter);
    8091        }
    8192      }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveOperator.cs

    r4369 r4370  
    3737    }
    3838
     39    public abstract ILookupParameter VRPMoveParameter { get; }
     40
    3941    [StorableConstructor]
    4042    protected VRPMoveOperator(bool deserializing) : base(deserializing) { }
Note: See TracChangeset for help on using the changeset viewer.