Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11905


Ignore:
Timestamp:
02/05/15 10:39:46 (10 years ago)
Author:
abeham
Message:

#2232: merged to stable

Location:
stable
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs

    r11170 r11905  
    3838  [Item("LocalSearchImprovementOperator", "A local search improvement operator.")]
    3939  [StorableClass]
    40   public sealed class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator {
     40  public sealed class LocalSearchImprovementOperator : SingleSuccessorOperator, ILocalImprovementAlgorithmOperator, IStochasticOperator {
    4141    #region IGenericLocalImprovementOperator Properties
    4242    public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } }
  • stable/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs

    r11170 r11905  
    3838  [Item("SimulatedAnnealingImprovementOperator", "A simulated annealing improvement operator.")]
    3939  [StorableClass]
    40   public sealed class SimulatedAnnealingImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator {
     40  public sealed class SimulatedAnnealingImprovementOperator : SingleSuccessorOperator, ILocalImprovementAlgorithmOperator, IStochasticOperator {
    4141    #region IGenericLocalImprovementOperator Properties
    4242    public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } }
  • stable/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/VariableNeighborhoodSearch.cs

    r11170 r11905  
    283283    private void ParameterizeLocalImprovementOperators() {
    284284      foreach (ILocalImprovementOperator op in LocalImprovementParameter.ValidValues) {
    285         if (op != LocalImprovementParameter.Value) op.Problem = null;
    286285        op.MaximumIterationsParameter.Value = null;
    287286        op.MaximumIterationsParameter.ActualName = LocalImprovementMaximumIterationsParameter.Name;
    288       }
    289       if (LocalImprovementParameter.Value != null)
    290         LocalImprovementParameter.Value.Problem = Problem;
     287
     288        var algOp = op as ILocalImprovementAlgorithmOperator;
     289        if (algOp != null && algOp != LocalImprovementParameter.Value) algOp.Problem = null;
     290      }
     291      if (LocalImprovementParameter.Value is ILocalImprovementAlgorithmOperator)
     292        ((ILocalImprovementAlgorithmOperator)LocalImprovementParameter.Value).Problem = Problem;
    291293    }
    292294    private void InitializeLocalImprovementOperators() {
    293       if (Problem == null) {
    294         LocalImprovementParameter.ValidValues.Clear();
    295       } else {
    296         foreach (var entry in LocalImprovementParameter.ValidValues.ToList()) {
    297           if (!entry.ProblemType.IsAssignableFrom(Problem.GetType())) {
    298             LocalImprovementParameter.ValidValues.Remove(entry);
    299           }
     295      LocalImprovementParameter.ValidValues.Clear();
     296      if (Problem != null) {
     297        // Regular ILocalImprovementOperators queried from Problem
     298        foreach (var op in Problem.Operators.OfType<ILocalImprovementOperator>().Where(x => !(x is ILocalImprovementAlgorithmOperator))) {
     299          LocalImprovementParameter.ValidValues.Add(op);
    300300        }
    301         foreach (ILocalImprovementOperator op in ApplicationManager.Manager.GetInstances<ILocalImprovementOperator>().Where(x => x.ProblemType.IsAssignableFrom(Problem.GetType()))) {
    302           if (!LocalImprovementParameter.ValidValues.Any(x => x.GetType() == op.GetType()))
     301        // ILocalImprovementAlgorithmOperators queried from ApplicationManager
     302        var algOps = ApplicationManager.Manager.GetInstances<ILocalImprovementAlgorithmOperator>()
     303                                               .Where(x => x.ProblemType.IsInstanceOfType(Problem));
     304        foreach (var op in algOps) {
     305          if (LocalImprovementParameter.ValidValues.All(x => x.GetType() != op.GetType()))
    303306            LocalImprovementParameter.ValidValues.Add(op);
    304307        }
  • stable/HeuristicLab.Optimization

  • stable/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r9438 r11905  
    114114  </ItemGroup>
    115115  <ItemGroup>
     116    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    116117    <Compile Include="Interfaces\ISingleObjectivePathRelinker.cs" />
    117118    <Compile Include="Interfaces\ISingleObjectiveImprovementOperator.cs" />
  • stable/HeuristicLab.Optimization/3.3/Interfaces/ILocalImprovementOperator.cs

    r11170 r11905  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Data;
     
    2625namespace HeuristicLab.Optimization {
    2726  public interface ILocalImprovementOperator : IOperator {
    28     Type ProblemType { get; }
    29     IProblem Problem { get; set; }
    3027    IValueLookupParameter<IntValue> MaximumIterationsParameter { get; }
    3128    ILookupParameter<IntValue> EvaluatedSolutionsParameter { get; }
  • stable/HeuristicLab.Problems.QuadraticAssignment

  • stable/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInsertionLocalImprovement.cs

    r11170 r11905  
    3535  [StorableClass]
    3636  public class QAPExhaustiveInsertionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator {
    37 
    38     public Type ProblemType {
    39       get { return typeof(QuadraticAssignmentProblem); }
    40     }
    41 
    42     [Storable]
    43     private QuadraticAssignmentProblem problem;
    44     public IProblem Problem {
    45       get { return problem; }
    46       set { problem = (QuadraticAssignmentProblem)value; }
    47     }
    4837
    4938    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    8776    protected QAPExhaustiveInsertionLocalImprovement(QAPExhaustiveInsertionLocalImprovement original, Cloner cloner)
    8877      : base(original, cloner) {
    89       this.problem = cloner.Clone(original.problem);
    9078    }
    9179    public QAPExhaustiveInsertionLocalImprovement()
  • stable/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInversionLocalImprovement.cs

    r11170 r11905  
    3535  [StorableClass]
    3636  public class QAPExhaustiveInversionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator {
    37 
    38     public Type ProblemType {
    39       get { return typeof(QuadraticAssignmentProblem); }
    40     }
    41 
    42     [Storable]
    43     private QuadraticAssignmentProblem problem;
    44     public IProblem Problem {
    45       get { return problem; }
    46       set { problem = (QuadraticAssignmentProblem)value; }
    47     }
    4837
    4938    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    8776    protected QAPExhaustiveInversionLocalImprovement(QAPExhaustiveInversionLocalImprovement original, Cloner cloner)
    8877      : base(original, cloner) {
    89       this.problem = cloner.Clone(original.problem);
    9078    }
    9179    public QAPExhaustiveInversionLocalImprovement()
  • stable/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs

    r11170 r11905  
    3535  [StorableClass]
    3636  public class QAPExhaustiveSwap2LocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator {
    37 
    38     public Type ProblemType {
    39       get { return typeof(QuadraticAssignmentProblem); }
    40     }
    41 
    42     [Storable]
    43     private QuadraticAssignmentProblem problem;
    44     public IProblem Problem {
    45       get { return problem; }
    46       set { problem = (QuadraticAssignmentProblem)value; }
    47     }
    4837
    4938    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    9180    protected QAPExhaustiveSwap2LocalImprovement(QAPExhaustiveSwap2LocalImprovement original, Cloner cloner)
    9281      : base(original, cloner) {
    93       this.problem = cloner.Clone(original.problem);
    9482    }
    9583    public QAPExhaustiveSwap2LocalImprovement()
  • stable/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPStochasticScrambleLocalImprovement.cs

    r11170 r11905  
    3535  [StorableClass]
    3636  public class QAPStochasticScrambleLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator {
    37 
    38     public Type ProblemType {
    39       get { return typeof(QuadraticAssignmentProblem); }
    40     }
    41 
    42     [Storable]
    43     private QuadraticAssignmentProblem problem;
    44     public IProblem Problem {
    45       get { return problem; }
    46       set { problem = (QuadraticAssignmentProblem)value; }
    47     }
    4837
    4938    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    9584    protected QAPStochasticScrambleLocalImprovement(QAPStochasticScrambleLocalImprovement original, Cloner cloner)
    9685      : base(original, cloner) {
    97       this.problem = cloner.Clone(original.problem);
    9886    }
    9987    public QAPStochasticScrambleLocalImprovement()
  • stable/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r11170 r11905  
    302302      Operators.Add(new QAPAlleleFrequencyAnalyzer());
    303303      Operators.Add(new QAPPopulationDiversityAnalyzer());
     304
     305      Operators.Add(new QAPExhaustiveInsertionLocalImprovement());
     306      Operators.Add(new QAPExhaustiveInversionLocalImprovement());
     307      Operators.Add(new QAPStochasticScrambleLocalImprovement());
    304308      Operators.Add(new QAPExhaustiveSwap2LocalImprovement());
     309
    305310      Operators.Add(new QAPSimilarityCalculator());
    306311      ParameterizeAnalyzers();
  • stable/HeuristicLab.Problems.VehicleRouting

  • stable/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs

    r11170 r11905  
    3737  [StorableClass]
    3838  public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator {
    39     public Type ProblemType {
    40       get { return typeof(VehicleRoutingProblem); }
    41     }
    42 
    43     [Storable]
    44     private VehicleRoutingProblem problem;
    45     public IProblem Problem {
    46       get { return problem; }
    47       set { problem = (VehicleRoutingProblem)value; }
    48     }
    4939
    5040    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     
    8474    protected AlbaLambdaInterchangeLocalImprovementOperator(AlbaLambdaInterchangeLocalImprovementOperator original, Cloner cloner)
    8575      : base(original, cloner) {
    86         this.problem = cloner.Clone(original.problem);
    8776    }
    8877    public AlbaLambdaInterchangeLocalImprovementOperator()
     
    10291    }
    10392
    104     public static void Apply(AlbaEncoding solution, int maxIterations, 
     93    public static void Apply(AlbaEncoding solution, int maxIterations,
    10594      int lambda, int samples, IRandom random, IVRPProblemInstance problemInstance, ref double quality, out int evaluatedSolutions) {
    10695      evaluatedSolutions = 0;
     
    120109          }
    121110        }
    122         if (bestMove != null) 
     111        if (bestMove != null)
    123112          AlbaLambdaInterchangeMoveMaker.Apply(solution, bestMove);
    124113      }
  • stable/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r11333 r11905  
    3333using HeuristicLab.PluginInfrastructure;
    3434using HeuristicLab.Problems.Instances;
     35using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    3536using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3637using HeuristicLab.Problems.VehicleRouting.Interpreters;
     
    263264            defaultCreator = creator;
    264265        }
     266        Operators.Add(new AlbaLambdaInterchangeLocalImprovementOperator());
    265267        if (defaultCreator != null)
    266268          solutionCreatorParameter.Value = defaultCreator;
Note: See TracChangeset for help on using the changeset viewer.