Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/30/15 15:12:34 (9 years ago)
Author:
mkommend
Message:

#2521: Adapted type discovery and type selector to allow the creation of generic programmable problems.

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

Legend:

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

    r13390 r13422  
    3434  [Creatable(CreatableAttribute.Categories.Problems, Priority = 120)]
    3535  [StorableClass]
    36   public abstract class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
     36  public class MultiObjectiveProgrammableProblem<TEncoding, TSolution> : MultiObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    3737    where TEncoding : class, IEncoding<TSolution>
    3838    where TSolution : class, ISolution {
     
    6666      RegisterEvents();
    6767    }
     68
     69    public override IDeepCloneable Clone(Cloner cloner) {
     70      return new MultiObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner);
     71    }
     72
    6873    public MultiObjectiveProgrammableProblem()
    6974      : base() {
     
    7176        new MultiObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name }));
    7277      ProblemScript.Encoding = (TEncoding)Encoding.Clone();
     78
     79      var codeTemplate = ScriptTemplates.MultiObjectiveProblem_Template;
     80      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, typeof(TEncoding).Namespace);
     81      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, typeof(TEncoding).Name);
     82      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TSolution).Name);
     83      ProblemScript.Code = codeTemplate;
     84
    7385      RegisterEvents();
    7486    }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs

    r13390 r13422  
    3434namespace HeuristicLab.Problems.Programmable {
    3535  [Item("Programmable Problem (single-objective)", "Represents a single-objective problem that can be programmed with a script.")]
     36  [Creatable(CreatableAttribute.Categories.Problems, Priority = 110)]
    3637  [StorableClass]
    37   public abstract class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
     38  public class SingleObjectiveProgrammableProblem<TEncoding, TSolution> : SingleObjectiveProblem<TEncoding, TSolution>, IProgrammableItem, IProgrammableProblem
    3839    where TEncoding : class, IEncoding<TSolution>
    3940    where TSolution : class, ISolution {
     
    6768      RegisterEvents();
    6869    }
     70
     71    public override IDeepCloneable Clone(Cloner cloner) {
     72      return new SingleObjectiveProgrammableProblem<TEncoding, TSolution>(this, cloner);
     73    }
     74
    6975    public SingleObjectiveProgrammableProblem()
    7076      : base() {
    71       Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.",
    72         new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name }));
     77      Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.", new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name }));
    7378      ProblemScript.Encoding = (TEncoding)Encoding.Clone();
     79
     80      var codeTemplate = ScriptTemplates.SingleObjectiveProblem_Template;
     81      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, typeof(TEncoding).Namespace);
     82      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, typeof(TEncoding).Name);
     83      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, typeof(TSolution).Name);
     84      ProblemScript.Code = codeTemplate;
     85
    7486      Operators.Add(new BestScopeSolutionAnalyzer());
    7587      RegisterEvents();
Note: See TracChangeset for help on using the changeset viewer.