Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/15 19:15:23 (9 years ago)
Author:
abeham
Message:

#2521: fixed template and bug in programmable problem with multi encoding

Location:
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r13385 r13390  
    3434  [Creatable(CreatableAttribute.Categories.Problems, Priority = 120)]
    3535  [StorableClass]
    36   public class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
     36  public abstract class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    3737    where TEncoding : class, IEncoding<TSolution>
    3838    where TSolution : class, ISolution {
     
    6060    }
    6161
     62    [StorableConstructor]
     63    protected MultiObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }
    6264    protected MultiObjectiveProgrammableProblem(MultiObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner)
    6365      : base(original, cloner) {
    6466      RegisterEvents();
    6567    }
    66     public override IDeepCloneable Clone(Cloner cloner) { return new MultiObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner); }
    67 
    68     [StorableConstructor]
    69     protected MultiObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }
    7068    public MultiObjectiveProgrammableProblem()
    7169      : base() {
     
    8886      Parameters.Remove("Maximization");
    8987      Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) { Hidden = true });
    90       var multiEnc = ProblemScript.Encoding as CombinedEncoding;
    91       if (multiEnc != null) multiEnc.Clear();
    9288      Encoding = (TEncoding)ProblemScript.Encoding.Clone();
    9389
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r13385 r13390  
    3535  [Item("Programmable Problem (single-objective)", "Represents a single-objective problem that can be programmed with a script.")]
    3636  [StorableClass]
    37   public class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
     37  public abstract class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    3838    where TEncoding : class, IEncoding<TSolution>
    3939    where TSolution : class, ISolution {
     
    5050    }
    5151
    52 
    5352    Script IProgrammableProblem.ProblemScript {
    5453      get { return ProblemScript; }
     
    6261    }
    6362
     63    [StorableConstructor]
     64    protected SingleObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }
    6465    protected SingleObjectiveProgrammableProblem(SingleObjectiveProgrammableProblem<TEncoding, TSolution> original, Cloner cloner)
    6566      : base(original, cloner) {
    6667      RegisterEvents();
    6768    }
    68     public override IDeepCloneable Clone(Cloner cloner) { return new SingleObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner); }
    69 
    70     [StorableConstructor]
    71     protected SingleObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { }
    7269    public SingleObjectiveProgrammableProblem()
    7370      : base() {
     
    9188      Parameters.Remove("Maximization");
    9289      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    93       var multiEnc = ProblemScript.Encoding as CombinedEncoding;
    94       if (multiEnc != null) multiEnc.Clear();
    9590      Encoding = (TEncoding)ProblemScript.Encoding.Clone();
    9691
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs

    r13380 r13390  
    2222      // Add additional initialization code e.g. private variables that you need for evaluating
    2323      //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
    24       //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } } });
    25       //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } } });
    26       //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });
     24      //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) });
     25      //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });
     26      //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute });
    2727      //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 });
    2828    }
     
    3131      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    3232      var quality = new[] { 0.0, 0.0 };
    33       // var b = solution.GetSolution<BinaryVector>("b");
    34       // quality[0] = b.Count(x => x); // one max!
    35       // var r = solution.GetSolution<RealVector>("r");
    36       // quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere
     33      //var b = solution.GetSolution<BinaryVector>("b");
     34      //quality[0] = b.Count(x => x); // one max!
     35      //var r = solution.GetSolution<RealVector>("r");
     36      //quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere
    3737
    3838      // NOTE: Check the Maximization property above (true or false)!
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveCombinedEncodingProblem_Template.cs

    r13380 r13390  
    2222      // Add additional initialization code e.g. private variables that you need for evaluating
    2323      //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
    24       //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } } });
    25       //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } } });
    26       //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });
     24      //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) });
     25      //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });
     26      //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute });
    2727      //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 });
    2828    }
     
    3131      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    3232      var quality = 0.0;
    33       // var b = solution.GetSolution<BinaryVector>("b");
    34       // quality = b.Count(x => x); // one max!
    35       // var r = solution.GetSolution<RealVector>("r");
    36       // quality += r.Sum(x => -x * x); // sphere
     33      //var b = solution.GetSolution<BinaryVector>("b");
     34      //quality = b.Count(x => x); // one max!
     35      //var r = solution.GetSolution<RealVector>("r");
     36      //quality += r.Sum(x => -x * x); // sphere
    3737
    3838      // NOTE: Check the Maximization property above (true or false)!
Note: See TracChangeset for help on using the changeset viewer.