Changeset 5609 for branches/VNS/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/LocalSearchImprovement.cs
- Timestamp:
- 03/04/11 17:23:40 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VNS/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/LocalSearchImprovement.cs
r5603 r5609 87 87 : base() { 88 88 loop = new LocalSearchMainLoop(); 89 loop.ResultsParameter.Value = new VariableCollection();90 89 91 90 Parameters.Add(new /*Constrained*/ValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution.")); … … 143 142 public override IOperation Apply() { 144 143 Scope subScope = new Scope(); 145 subScope.Parent = ExecutionContext.Scope;144 Scope individual = new Scope(); 146 145 147 IAtomicOperation op = ExecutionContext.CreateChildOperation(loop, subScope); 148 op.Operator.Execute((IExecutionContext)op, CancellationToken); 146 foreach (Variable var in ExecutionContext.Scope.Variables) { 147 individual.Variables.Add(var); 148 } 149 subScope.SubScopes.Add(individual); 149 150 150 ExecutionContext.Scope.SubScopes.Remove(subScope); 151 ExecutionContext.Scope.SubScopes.Add(subScope); 152 int index = subScope.Parent.SubScopes.IndexOf(subScope); 151 153 152 return base.Apply(); 154 SubScopesProcessor processor = new SubScopesProcessor(); 155 SubScopesRemover remover = new SubScopesRemover(); 156 157 remover.RemoveAllSubScopes = false; 158 remover.SubScopeIndexParameter.Value = new IntValue(index); 159 160 for (int i = 0; i < index; i++) { 161 processor.Operators.Add(new EmptyOperator()); 162 } 163 164 loop.MoveGeneratorParameter.Value = MoveGeneratorParameter.Value; 165 loop.MoveEvaluatorParameter.Value = MoveEvaluatorParameter.Value; 166 loop.MoveMakerParameter.Value = MoveMakerParameter.Value; 167 loop.MaximumIterationsParameter.Value = MaximumIterationsParameter.Value; 168 169 processor.Operators.Add(loop); 170 processor.Successor = remover; 171 172 IOperation next = base.Apply(); 173 if (next as ExecutionContext != null) { 174 remover.Successor = (next as ExecutionContext).Operator; 175 } 176 177 return ExecutionContext.CreateOperation(processor); 153 178 } 154 179 }
Note: See TracChangeset
for help on using the changeset viewer.