Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4757


Ignore:
Timestamp:
11/09/10 15:46:55 (14 years ago)
Author:
abeham
Message:

#1258

  • worked on parameter binding (wip)
Location:
branches/ParameterBinding
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ParameterBinding/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs

    r4722 r4757  
    3333  public abstract class ParameterizedNamedItem : NamedItem, IParameterizedNamedItem {
    3434    [Storable]
     35    private List<IParameterBinding> parameterBindingList;
     36    // eventuelly this should be made public and exposed in a view so that the algorithm designer can add bindings in the GUI
     37    protected List<IParameterBinding> ParameterBindingList {
     38      get { return parameterBindingList; }
     39    }
     40    [Storable]
    3541    private ParameterCollection parameters;
    3642    protected ParameterCollection Parameters {
     
    5056      : base(original, cloner) {
    5157      parameters = cloner.Clone(original.parameters);
     58      parameterBindingList = original.parameterBindingList.Select(x => cloner.Clone(x)).ToList();
    5259      readOnlyParameters = null;
    5360    }
     
    5663      name = ItemName;
    5764      description = ItemDescription;
     65      parameterBindingList = new List<IParameterBinding>();
    5866      parameters = new ParameterCollection();
    5967      readOnlyParameters = null;
     
    6270      : base(name) {
    6371      description = ItemDescription;
     72      parameterBindingList = new List<IParameterBinding>();
    6473      parameters = new ParameterCollection();
    6574      readOnlyParameters = null;
     
    6877      : base(name) {
    6978      description = ItemDescription;
     79      parameterBindingList = new List<IParameterBinding>();
    7080      this.parameters = parameters;
    7181      readOnlyParameters = null;
     
    7383    protected ParameterizedNamedItem(string name, string description)
    7484      : base(name, description) {
     85      parameterBindingList = new List<IParameterBinding>();
    7586      parameters = new ParameterCollection();
    7687      readOnlyParameters = null;
     
    7889    protected ParameterizedNamedItem(string name, string description, ParameterCollection parameters)
    7990      : base(name, description) {
     91      parameterBindingList = new List<IParameterBinding>();
    8092      this.parameters = parameters;
    8193      readOnlyParameters = null;
  • branches/ParameterBinding/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r4722 r4757  
    239239      ParameterizeAnalyzers();
    240240    }
    241     private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    242       string name = ((ILookupParameter<InversionMove>)sender).ActualName;
    243       foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>()) {
    244         op.InversionMoveParameter.ActualName = name;
    245       }
    246     }
    247241    private void MoveGenerator_TranslocationMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    248242      string name = ((ILookupParameter<TranslocationMove>)sender).ActualName;
     
    285279    }
    286280    private void InitializeMoveGenerators() {
    287       foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>()) {
    288         if (op is IMoveGenerator) {
    289           op.InversionMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_InversionMoveParameter_ActualNameChanged);
     281      foreach (IPermutationInversionMoveOperator moveGen in Operators.OfType<IMoveGenerator>().OfType<IPermutationInversionMoveOperator>()) {
     282        foreach (IPermutationInversionMoveOperator moveOp in Operators.Where(x => ! (x is IMoveGenerator)).OfType<IPermutationInversionMoveOperator>()) {
     283          ParameterActualNameBinding binding = new ParameterActualNameBinding(
     284            moveGen.InversionMoveParameter,
     285            moveOp.InversionMoveParameter);
     286          ParameterBindingList.Add(binding);
     287          binding.Bind();
    290288        }
    291289      }
    292       foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>()) {
    293         if (op is IMoveGenerator) {
    294           op.TranslocationMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_TranslocationMoveParameter_ActualNameChanged);
     290      foreach (IPermutationTranslocationMoveOperator moveGen in Operators.OfType<IMoveGenerator>().OfType<IPermutationTranslocationMoveOperator>()) {
     291        foreach (IPermutationTranslocationMoveOperator moveOp in Operators.Where(x => !(x is IMoveGenerator)).OfType<IPermutationTranslocationMoveOperator>()) {
     292          ParameterActualNameBinding binding = new ParameterActualNameBinding(
     293            moveGen.TranslocationMoveParameter,
     294            moveOp.TranslocationMoveParameter);
     295          ParameterBindingList.Add(binding);
     296          binding.Bind();
    295297        }
    296298      }
     
    310312    }
    311313    private void ParameterizeEvaluator() {
     314      ParameterSecondLevelActualNameBinding binding = new ParameterSecondLevelActualNameBinding(
     315        SolutionCreatorParameter, EvaluatorParameter,
     316        "PermutationParameter", "PermutationParameter"
     317        );
     318      ParameterBindingList.Add(binding);
     319      binding.Bind();
     320
    312321      if (Evaluator is ITSPPathEvaluator)
    313322        ((ITSPPathEvaluator)Evaluator).PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
Note: See TracChangeset for help on using the changeset viewer.