Changeset 17778
- Timestamp:
- 10/29/20 14:44:19 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/ArtificialAnt/Problem.cs
r17745 r17778 78 78 79 79 #region Parameter Properties 80 public IValueParameter<BoolMatrix> WorldParameter { 81 get { return (IValueParameter<BoolMatrix>)Parameters["World"]; } 82 } 83 public IFixedValueParameter<IntValue> MaxTimeStepsParameter { 84 get { return (IFixedValueParameter<IntValue>)Parameters["MaximumTimeSteps"]; } 85 } 80 [Storable] public IValueParameter<BoolMatrix> WorldParameter { get; private set; } 81 [Storable] public IFixedValueParameter<IntValue> MaxTimeStepsParameter { get; private set; } 86 82 #endregion 87 83 … … 105 101 106 102 // cloning 107 private Problem(Problem original, Cloner cloner) : base(original, cloner) { } 103 private Problem(Problem original, Cloner cloner) : base(original, cloner) { 104 WorldParameter = cloner.Clone(original.WorldParameter); 105 MaxTimeStepsParameter = cloner.Clone(original.MaxTimeStepsParameter); 106 } 108 107 public override IDeepCloneable Clone(Cloner cloner) { 109 108 return new Problem(this, cloner); … … 114 113 Maximization = true; 115 114 BoolMatrix world = new BoolMatrix(ToBoolMatrix(santaFeAntTrail)); 116 Parameters.Add( new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));117 Parameters.Add( new FixedValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));115 Parameters.Add(WorldParameter = new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world)); 116 Parameters.Add(MaxTimeStepsParameter = new FixedValueParameter<IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600))); 118 117 119 118 var g = new SimpleSymbolicExpressionGrammar(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/BasicSymbolicRegression/Problem.cs
r17655 r17778 39 39 [StorableType("72011B73-28C6-4D5E-BEDF-27425BC87B9C")] 40 40 public sealed class Problem : SymbolicExpressionTreeProblem, IRegressionProblem, IProblemInstanceConsumer<IRegressionProblemData>, IProblemInstanceExporter<IRegressionProblemData> { 41 42 #region parameter names 43 private const string ProblemDataParameterName = "ProblemData"; 44 #endregion 45 41 46 42 #region Parameter Properties 47 public IValueParameter<IRegressionProblemData> ProblemDataParameter { 48 get { return (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; } 49 } 43 [Storable] public IValueParameter<IRegressionProblemData> ProblemDataParameter { get; private set; } 50 44 #endregion 51 45 … … 72 66 private Problem(Problem original, Cloner cloner) 73 67 : base(original, cloner) { 68 ProblemDataParameter = cloner.Clone(original.ProblemDataParameter); 74 69 RegisterEventHandlers(); 75 70 } … … 79 74 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 80 75 Maximization = true; 81 Parameters.Add( new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, "The data for the regression problem", new RegressionProblemData()));76 Parameters.Add(ProblemDataParameter = new ValueParameter<IRegressionProblemData>("ProblemData", "The data for the regression problem", new RegressionProblemData())); 82 77 83 78 Encoding.TreeLength = 100; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/EvenParityProblem.cs
r17655 r17778 39 39 public sealed class EvenParityProblem : SymbolicExpressionTreeProblem { 40 40 41 #region parameter names42 private const string NumberOfBitsParameterName = "NumberOfBits";43 #endregion44 45 41 #region Parameter Properties 46 public IFixedValueParameter<IntValue> NumberOfBitsParameter { 47 get { return (IFixedValueParameter<IntValue>)Parameters[NumberOfBitsParameterName]; } 48 } 42 [Storable] public IFixedValueParameter<IntValue> NumberOfBitsParameter { get; private set; } 49 43 #endregion 50 44 … … 68 62 private EvenParityProblem(EvenParityProblem original, Cloner cloner) 69 63 : base(original, cloner) { 64 NumberOfBitsParameter = cloner.Clone(original.NumberOfBitsParameter); 70 65 RegisterEventHandlers(); 71 66 } … … 78 73 : base(new SymbolicExpressionTreeEncoding()) { 79 74 Maximization = true; 80 Parameters.Add( new FixedValueParameter<IntValue>(NumberOfBitsParameterName, "The number of bits for the input parameter for the even parity function", new IntValue(4)));75 Parameters.Add(NumberOfBitsParameter = new FixedValueParameter<IntValue>("NumberOfBits", "The number of bits for the input parameter for the even parity function", new IntValue(4))); 81 76 82 77 Encoding.TreeLength = 100; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/Boolean/MultiplexerProblem.cs
r17655 r17778 41 41 public sealed class MultiplexerProblem : SymbolicExpressionTreeProblem { 42 42 43 #region parameter names44 private const string NumberOfBitsParameterName = "NumberOfBits";45 #endregion46 47 43 #region Parameter Properties 48 public IFixedValueParameter<IntValue> NumberOfBitsParameter { 49 get { return (IFixedValueParameter<IntValue>)Parameters[NumberOfBitsParameterName]; } 50 } 44 [Storable] public IFixedValueParameter<IntValue> NumberOfBitsParameter { get; private set; } 51 45 #endregion 52 46 … … 70 64 private MultiplexerProblem(MultiplexerProblem original, Cloner cloner) 71 65 : base(original, cloner) { 66 NumberOfBitsParameter = cloner.Clone(original.NumberOfBitsParameter); 72 67 RegisterEventHandlers(); 73 68 } … … 81 76 : base(new SymbolicExpressionTreeEncoding()) { 82 77 Maximization = true; 83 Parameters.Add( new FixedValueParameter<IntValue>(NumberOfBitsParameterName,78 Parameters.Add(NumberOfBitsParameter = new FixedValueParameter<IntValue>("NumberOfBits", 84 79 "The number of bits for the input parameter for the multiplexer function. This is the sum of the number of address bits and the number of input lines. E.g. the 11-MUX has 3 address bits and 8 input lines", 85 80 new IntValue(11))); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/LawnMower/Problem.cs
r17745 r17778 35 35 [Item("Lawn Mower Problem", "The lawn mower demo problem for genetic programming.")] 36 36 public class Problem : SymbolicExpressionTreeProblem { 37 private const string LawnWidthParameterName = "LawnWidth"; 38 private const string LawnLengthParameterName = "LawnLength"; 39 40 public IFixedValueParameter<IntValue> LawnWidthParameter { 41 get { return (IFixedValueParameter<IntValue>)Parameters[LawnWidthParameterName]; } 42 } 43 public IFixedValueParameter<IntValue> LawnLengthParameter { 44 get { return (IFixedValueParameter<IntValue>)Parameters[LawnLengthParameterName]; } 45 } 37 [Storable] public IFixedValueParameter<IntValue> LawnWidthParameter { get; private set; } 38 [Storable] public IFixedValueParameter<IntValue> LawnLengthParameter { get; private set; } 46 39 47 40 #region item cloning and persistence … … 51 44 private void AfterDeserialization() { } 52 45 53 protected Problem(Problem original, Cloner cloner) : base(original, cloner) { } 46 protected Problem(Problem original, Cloner cloner) : base(original, cloner) { 47 LawnWidthParameter = cloner.Clone(original.LawnWidthParameter); 48 LawnLengthParameter = cloner.Clone(original.LawnLengthParameter); 49 } 54 50 public override IDeepCloneable Clone(Cloner cloner) { 55 51 return new Problem(this, cloner); … … 59 55 public Problem() : base(new SymbolicExpressionTreeEncoding()) { 60 56 Maximization = true; 61 Parameters.Add( new FixedValueParameter<IntValue>(LawnWidthParameterName, "Width of the lawn.", new IntValue(8)));62 Parameters.Add( new FixedValueParameter<IntValue>(LawnLengthParameterName, "Length of the lawn.", new IntValue(8)));57 Parameters.Add(LawnWidthParameter = new FixedValueParameter<IntValue>("LawnWidth", "Width of the lawn.", new IntValue(8))); 58 Parameters.Add(LawnLengthParameter = new FixedValueParameter<IntValue>("LawnLength", "Length of the lawn.", new IntValue(8))); 63 59 64 60 var g = new SimpleSymbolicExpressionGrammar(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GeneticProgramming/3.3/robocode/Problem.cs
r17745 r17778 34 34 [Item("Robocode Problem", "Evolution of a robocode program in java using genetic programming.")] 35 35 public class Problem : SymbolicExpressionTreeProblem { 36 #region Parameter Names 37 private const string RobocodePathParamaterName = "RobocodePath"; 38 private const string NrOfRoundsParameterName = "NrOfRounds"; 39 private const string EnemiesParameterName = "Enemies"; 40 #endregion 41 36 42 37 #region Parameters 43 public IFixedValueParameter<DirectoryValue> RobocodePathParameter { 44 get { return (IFixedValueParameter<DirectoryValue>)Parameters[RobocodePathParamaterName]; } 45 } 46 public IFixedValueParameter<IntValue> NrOfRoundsParameter { 47 get { return (IFixedValueParameter<IntValue>)Parameters[NrOfRoundsParameterName]; } 48 } 49 public IValueParameter<EnemyCollection> EnemiesParameter { 50 get { return (IValueParameter<EnemyCollection>)Parameters[EnemiesParameterName]; } 51 } 38 [Storable] public IFixedValueParameter<DirectoryValue> RobocodePathParameter { get; private set; } 39 [Storable] public IFixedValueParameter<IntValue> NrOfRoundsParameter { get; private set; } 40 [Storable] public IValueParameter<EnemyCollection> EnemiesParameter { get; private set; } 52 41 53 42 public string RobocodePath { … … 71 60 protected Problem(Problem original, Cloner cloner) 72 61 : base(original, cloner) { 62 RobocodePathParameter = cloner.Clone(original.RobocodePathParameter); 63 NrOfRoundsParameter = cloner.Clone(original.NrOfRoundsParameter); 64 EnemiesParameter = cloner.Clone(original.EnemiesParameter); 65 73 66 RegisterEventHandlers(); 74 67 } … … 82 75 83 76 84 Parameters.Add( new FixedValueParameter<DirectoryValue>(RobocodePathParamaterName, "Path of the Robocode installation.", robocodeDir));85 Parameters.Add( new FixedValueParameter<IntValue>(NrOfRoundsParameterName, "Number of rounds a robot has to fight against each opponent.", new IntValue(3)));86 Parameters.Add( new ValueParameter<EnemyCollection>(EnemiesParameterName, "The enemies that should be battled.", robotList));77 Parameters.Add(RobocodePathParameter = new FixedValueParameter<DirectoryValue>("RobocodePath", "Path of the Robocode installation.", robocodeDir)); 78 Parameters.Add(NrOfRoundsParameter = new FixedValueParameter<IntValue>("NrOfRounds", "Number of rounds a robot has to fight against each opponent.", new IntValue(3))); 79 Parameters.Add(EnemiesParameter = new ValueParameter<EnemyCollection>("Enemies", "The enemies that should be battled.", robotList)); 87 80 88 81 Encoding.FunctionArguments = 0; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs
r17745 r17778 43 43 IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> { 44 44 45 [Storable] 46 private IValueParameter<IntMatrix> adjacencyListParameter; 47 public IValueParameter<IntMatrix> AdjacencyListParameter { 48 get { return adjacencyListParameter; } 49 } 50 [Storable] 51 private IValueParameter<EnumValue<FitnessFunction>> fitnessFunctionParameter; 52 public IValueParameter<EnumValue<FitnessFunction>> FitnessFunctionParameter { 53 get { return fitnessFunctionParameter; } 54 } 45 [Storable] public IValueParameter<IntMatrix> AdjacencyListParameter { get; private set; } 46 [Storable] public IValueParameter<EnumValue<FitnessFunction>> FitnessFunctionParameter { get; private set; } 47 [Storable] public IValueParameter<IntValue> BestKnownColorsParameter { get; private set; } 48 [Storable] public IResult<IntValue> BestSolutionColorsResult { get; private set; } 49 [Storable] public IResult<IntValue> BestSolutionConflicts { get; private set; } 50 55 51 public FitnessFunction FitnessFunction { 56 get { return fitnessFunctionParameter.Value.Value; } 57 set { fitnessFunctionParameter.Value.Value = value; } 58 } 59 [Storable] 60 private IValueParameter<IntValue> bestKnownColorsParameter; 61 public IValueParameter<IntValue> BestKnownColorsParameter { 62 get { return bestKnownColorsParameter; } 52 get { return FitnessFunctionParameter.Value.Value; } 53 set { FitnessFunctionParameter.Value.Value = value; } 63 54 } 64 55 … … 67 58 private GraphColoringProblem(GraphColoringProblem original, Cloner cloner) 68 59 : base(original, cloner) { 69 adjacencyListParameter = cloner.Clone(original.adjacencyListParameter);70 fitnessFunctionParameter = cloner.Clone(original.fitnessFunctionParameter);71 bestKnownColorsParameter = cloner.Clone(original.bestKnownColorsParameter);60 AdjacencyListParameter = cloner.Clone(original.AdjacencyListParameter); 61 FitnessFunctionParameter = cloner.Clone(original.FitnessFunctionParameter); 62 BestKnownColorsParameter = cloner.Clone(original.BestKnownColorsParameter); 72 63 RegisterEventHandlers(); 73 64 } 74 65 public GraphColoringProblem() { 75 66 Maximization = false; 76 Parameters.Add(adjacencyListParameter = new ValueParameter<IntMatrix>("Adjacency List", "The adjacency list that describes the (symmetric) edges in the graph with nodes from 0 to N-1.") { ReadOnly = true }); 77 Parameters.Add(fitnessFunctionParameter = new ValueParameter<EnumValue<FitnessFunction>>("Fitness Function", "The function to use for evaluating the quality of a solution.", new EnumValue<FitnessFunction>(FitnessFunction.Penalized))); 78 Parameters.Add(bestKnownColorsParameter = new OptionalValueParameter<IntValue>("BestKnownColors", "The least amount of colors in a valid coloring.") { ReadOnly = true }); 67 Parameters.Add(AdjacencyListParameter = new ValueParameter<IntMatrix>("Adjacency List", "The adjacency list that describes the (symmetric) edges in the graph with nodes from 0 to N-1.") { ReadOnly = true }); 68 Parameters.Add(FitnessFunctionParameter = new ValueParameter<EnumValue<FitnessFunction>>("Fitness Function", "The function to use for evaluating the quality of a solution.", new EnumValue<FitnessFunction>(FitnessFunction.Penalized))); 69 Parameters.Add(BestKnownColorsParameter = new OptionalValueParameter<IntValue>("BestKnownColors", "The least amount of colors in a valid coloring.") { ReadOnly = true }); 70 Results.Add(BestSolutionColorsResult = new Result<IntValue>("Best Solution Colors", "The number of best solution found so far.")); 79 71 80 72 var imat = new IntMatrix(defaultInstance.Length, 2); … … 104 96 105 97 private void RegisterEventHandlers() { 106 fitnessFunctionParameter.ValueChanged += FitnessFunctionParameterOnValueChanged;107 fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;98 FitnessFunctionParameter.ValueChanged += FitnessFunctionParameterOnValueChanged; 99 FitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged; 108 100 } 109 101 110 102 private void FitnessFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) { 111 fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;103 FitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged; 112 104 FitnessFunctionOnValueChanged(sender, eventArgs); 113 105 } … … 126 118 127 119 public override ISingleObjectiveEvaluationResult Evaluate(LinearLinkage lle, IRandom random, CancellationToken cancellationToken) { 128 var adjList = adjacencyListParameter.Value;120 var adjList = AdjacencyListParameter.Value; 129 121 var llee = lle.ToEndLinks(); // LLE-e encoding uses the highest indexed member as group number 130 122
Note: See TracChangeset
for help on using the changeset viewer.