Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17696


Ignore:
Timestamp:
07/23/20 17:39:40 (4 years ago)
Author:
abeham
Message:

#2521:

  • fixed bug in EngineAlgorithm in Problem setter
  • Added storable type to IEncodedProblem
  • fixed some bugs and tests
Location:
branches/2521_ProblemRefactoring
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.ExactOptimization/3.3/LinearProgramming/Problems/LinearProblem.cs

    r17226 r17696  
    4343
    4444    public LinearProblem() {
    45       Parameters.Remove(Parameters["Operators"]);
    4645      Parameters.Add(problemDefinitionParam = new ValueParameter<ILinearProblemDefinition>("Model", "The linear programming problem",
    4746        new ProgrammableLinearProblemDefinition()) { GetsCollected = false });
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs

    r17614 r17696  
    5252    public new IEncodedProblem Problem {
    5353      get { return (IEncodedProblem)base.Problem; }
    54       set { base.Problem = Problem; }
     54      set { base.Problem = value; }
    5555    }
    5656
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblem.cs

    r17614 r17696  
    4242  //TODO ABE: We can maybe use it as non-generic interface that exports IEncoding Encoding { get; }
    4343  //TODO ABE: and which is explicitely implemented in some base class
     44  [StorableType("1dbe48d6-c008-4e40-86ad-c222450a3187")]
    4445  public interface IEncodedProblem : IProblem {
    4546    IEnumerable<IItem> Operators { get; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs

    r17695 r17696  
    2525using System.Threading;
    2626using HEAL.Attic;
    27 using HeuristicLab.Analysis;
    2827using HeuristicLab.Common;
    2928using HeuristicLab.Core;
     
    3130using HeuristicLab.Encodings.PermutationEncoding;
    3231using HeuristicLab.Optimization;
    33 using HeuristicLab.Optimization.Operators;
    3432using HeuristicLab.Parameters;
    35 using HeuristicLab.PluginInfrastructure;
    3633
    3734namespace HeuristicLab.Problems.LinearAssignment {
     
    119116      Costs[2, 0] = 5; Costs[2, 1] = 5; Costs[2, 2] = 1;
    120117
    121       InitializeOperators();
    122       Parameterize();
     118      Operators.RemoveAll(x => x is IMoveOperator);
    123119      AttachEventHandlers();
    124120    }
     
    194190
    195191    #region Events
    196     protected override void OnOperatorsChanged() {
    197       base.OnOperatorsChanged();
    198       Parameterize();
    199     }
    200192    private void Costs_RowsChanged(object sender, EventArgs e) {
    201193      if (Costs.Rows != Costs.Columns) {
    202194        ((IStringConvertibleMatrix)Costs).Columns = Costs.Rows;
    203         Parameterize();
     195        Dimension = Costs.Rows;
    204196      }
    205197    }
     
    207199      if (Costs.Rows != Costs.Columns) {
    208200        ((IStringConvertibleMatrix)Costs).Rows = Costs.Columns;
    209         Parameterize();
     201        Dimension = Costs.Rows;
    210202      }
    211203    }
    212204    private void Costs_Reset(object sender, EventArgs e) {
    213       Parameterize();
    214     }
    215     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    216       Parameterize();
     205      Dimension = Costs.Rows;
    217206    }
    218207    #endregion
     
    229218      Costs.Reset += new EventHandler(Costs_Reset);
    230219    }
    231 
    232     private void InitializeOperators() {
    233       Operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>());
    234       Operators.RemoveAll(x => x is IMoveOperator);
    235 
    236       Operators.Add(new HammingSimilarityCalculator());
    237       Operators.Add(new QualitySimilarityCalculator());
    238       Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    239     }
    240 
    241     private void Parameterize() {
    242       if (Costs.Rows != Dimension) Dimension = Costs.Rows;
    243       foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
    244         similarityCalculator.SolutionVariableName = Encoding.Name;
    245         similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
    246       }
    247     }
    248220    #endregion
    249221  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/CollectObjectGraphTest.cs

    r17226 r17696  
    3030using HeuristicLab.Optimization;
    3131using HeuristicLab.Problems.TestFunctions;
     32using HeuristicLab.Problems.TravelingSalesman;
    3233using Microsoft.VisualStudio.TestTools.UnitTesting;
    3334
     
    4950    [TestProperty("Time", "medium")]
    5051    public void TestObjectGraphTraversal() {
     52      /* TODO, sample does not load (SolutionCreatorParameter moved from Problem to Algorithm)
     53       * TODO, this is more of a serialization test?
    5154      GeneticAlgorithm ga = (GeneticAlgorithm)serializer.Deserialize(@"Test Resources\GA_SymbReg.hl");
    5255      var objects = ga.GetObjectGraphObjects().ToList();
     
    5457      // Should be 3982, but count may change slightly as members are added or removed
    5558      Assert.IsTrue(objects.Count > 1, "Number of objects in the object graph seems to small.");
     59      */
     60      var ga = new GeneticAlgorithm();
     61      ga.Problem = new TSP();
     62      var objects = ga.GetObjectGraphObjects().ToList();
     63      Assert.IsTrue(objects.Count > 1000, "Number of objects in the object graph seems to small.");
    5664    }
    5765
     
    6169    [TestProperty("Time", "medium")]
    6270    public void CollectGASample() {
     71      /* TODO, sample does not load (SolutionCreatorParameter moved from Problem to Algorithm)
    6372      GeneticAlgorithm ga = (GeneticAlgorithm)serializer.Deserialize(@"Test Resources\GA_SymbReg.hl");
    6473
     
    100109      }
    101110      TestContext.WriteLine("");
     111      */
    102112    }
    103113
  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/DeepCloneableCloningTest.cs

    r17543 r17696  
    4949        typeof (HeuristicLab.Problems.DataAnalysis.RegressionEnsembleSolution),
    5050        typeof (HeuristicLab.Problems.TravelingSalesman.EuclideanTSPData),
     51        typeof (HeuristicLab.Problems.TravelingSalesman.MatrixTSPData)
    5152      };
    5253      excludedTypes.Add(typeof(SymbolicExpressionGrammar).Assembly.GetType("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.EmptySymbolicExpressionTreeGrammar"));
Note: See TracChangeset for help on using the changeset viewer.