Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3109 for trunk


Ignore:
Timestamp:
03/19/10 10:46:02 (15 years ago)
Author:
svonolfe
Message:

Implemented review comments (#917)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Knapsack.cs

    r3107 r3109  
    5252      get { return (ValueParameter<IntValue>)Parameters["KnapsackCapacity"]; }
    5353    }
     54    public ValueParameter<IntArray> WeightsParameter {
     55      get { return (ValueParameter<IntArray>)Parameters["Weights"]; }
     56    }
     57    public ValueParameter<IntArray> ValuesParameter {
     58      get { return (ValueParameter<IntArray>)Parameters["Values"]; }
     59    }
    5460    public ValueParameter<DoubleValue> PenaltyParameter {
    5561      get { return (ValueParameter<DoubleValue>)Parameters["Penalty"]; }
    5662    }
    57     public ValueParameter<IntArray> WeightsParameter {
    58       get { return (ValueParameter<IntArray>)Parameters["Weights"]; }
    59     }
    60     public ValueParameter<IntArray> ValuesParameter {
    61       get { return (ValueParameter<IntArray>)Parameters["Values"]; }
    62     }
    6363    public ValueParameter<IBinaryVectorCreator> SolutionCreatorParameter {
    6464      get { return (ValueParameter<IBinaryVectorCreator>)Parameters["SolutionCreator"]; }
     
    8585
    8686    #region Properties
     87    public IntValue KnapsackCapacity {
     88      get { return KnapsackCapacityParameter.Value; }
     89      set { KnapsackCapacityParameter.Value = value; }
     90    }
     91    public IntArray Weights {
     92      get { return WeightsParameter.Value; }
     93      set { WeightsParameter.Value = value; }
     94    }
     95    public IntArray Values {
     96      get { return ValuesParameter.Value; }
     97      set { ValuesParameter.Value = value; }
     98    }
     99    public DoubleValue Penalty {
     100      get { return PenaltyParameter.Value; }
     101      set { PenaltyParameter.Value = value; }
     102    }
    87103    public IBinaryVectorCreator SolutionCreator {
    88104      get { return SolutionCreatorParameter.Value; }
     
    123139      Parameters.Add(new ValueParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack.", new IntValue(0)));
    124140      Parameters.Add(new ValueParameter<IntArray>("Weights", "The weights of the items.", new IntArray(5)));
    125       WeightsParameter.ActualValue.ToStringChanged += new EventHandler(WeightsActualValue_ToStringChanged);
    126141      Parameters.Add(new ValueParameter<IntArray>("Values", "The values of the items.", new IntArray(5)));
    127       ValuesParameter.ActualValue.ToStringChanged += new EventHandler(ValuesActualValue_ToStringChanged);
    128142      Parameters.Add(new ValueParameter<DoubleValue>("Penalty", "The penalty value for each unit of overweight.", new DoubleValue(1)));
    129143      Parameters.Add(new ValueParameter<IBinaryVectorCreator>("SolutionCreator", "The operator which should be used to create new Knapsack solutions.", creator));
     
    160174    }
    161175    public event EventHandler VisualizerChanged;
     176    private void OnVisualizerChanged() {
     177      if (VisualizerChanged != null)
     178        VisualizerChanged(this, EventArgs.Empty);
     179    }
     180
    162181    public event EventHandler OperatorsChanged;
    163182    private void OnOperatorsChanged() {
     
    181200      OnEvaluatorChanged();
    182201    }
    183 
    184     void ValuesActualValue_ToStringChanged(object sender, EventArgs e) {
    185       ParameterizeSolutionCreator();
    186     }
    187 
    188     void WeightsActualValue_ToStringChanged(object sender, EventArgs e) {
    189       ParameterizeSolutionCreator();
     202    void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) {
     203      ParameterizeEvaluator();
     204    }
     205    void WeightsParameter_ValueChanged(object sender, EventArgs e) {
     206      ParameterizeEvaluator();
     207    }
     208    void ValuesParameter_ValueChanged(object sender, EventArgs e) {
     209      ParameterizeEvaluator();
     210    }
     211    void PenaltyParameter_ValueChanged(object sender, EventArgs e) {
     212      ParameterizeEvaluator();
    190213    }
    191214    #endregion
     
    198221      SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    199222      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
     223      KnapsackCapacityParameter.ValueChanged += new EventHandler(KnapsackCapacityParameter_ValueChanged);
     224      WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
     225      ValuesParameter.ValueChanged += new EventHandler(ValuesParameter_ValueChanged);
     226      PenaltyParameter.ValueChanged += new EventHandler(PenaltyParameter_ValueChanged);
    200227    }
    201228    private void ParameterizeSolutionCreator() {
     
    209236          (KnapsackEvaluator)Evaluator;
    210237        knapsackEvaluator.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName;
     238        knapsackEvaluator.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;
    211239        knapsackEvaluator.WeightsParameter.ActualName = WeightsParameter.Name;
    212240        knapsackEvaluator.ValuesParameter.ActualName = ValuesParameter.Name;
    213         knapsackEvaluator.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;
    214241        knapsackEvaluator.PenaltyParameter.ActualName = PenaltyParameter.Name;
    215242      }
Note: See TracChangeset for help on using the changeset viewer.