Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17694


Ignore:
Timestamp:
07/23/20 14:18:19 (4 years ago)
Author:
abeham
Message:

#2521: fixed encoding change of JSSP, added tostring and itemimage change to ValueChanged event of ReferenceParameter

Location:
branches/2521_ProblemRefactoring
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ReferenceParameter.cs

    r17594 r17694  
    110110    }
    111111
     112    // TODO: Remove
     113    //protected void ChangeReference(IValueParameter newReference, bool retainData) {
     114    //  IItem oldValue = Value;
     115    //  var oldRef = ReferencedParameter;
     116    //  oldRef.ToStringChanged -= (o, e) => OnToStringChanged();
     117    //  oldRef.ItemImageChanged -= (o, e) => OnItemImageChanged();
     118    //  if (valueChanged != null) oldRef.ValueChanged -= OnReferencedParameterValueChanged;
     119    //  newReference.ToStringChanged += (o, e) => OnToStringChanged();
     120    //  newReference.ItemImageChanged += (o, e) => OnItemImageChanged();
     121    //  if (valueChanged != null) newReference.ValueChanged += OnReferencedParameterValueChanged;
     122    //  ReferencedParameter = newReference;
     123    //  oldRef.Value = (IItem)oldValue.Clone(); // This is problematic, e.g. FixedValueParameter !!! But necessary, otherwise the value holds reference to the old parameter
     124    //  if (retainData) Value = oldValue;
     125    //}
     126
    112127
    113128    #region event handlers
     
    128143    private void OnReferencedParameterValueChanged(object sender, EventArgs args) {
    129144      valueChanged?.Invoke(this, args); // note "this", not "sender" as sender would be the referenced parameter
     145      OnItemImageChanged();
     146      OnToStringChanged();
    130147    }
    131148
     
    166183      return new ReferenceParameter<T>(this, cloner);
    167184    }
     185
     186    // TODO: Remove
     187    //public void ChangeReference(IValueParameter<T> newParameter, bool retainData) {
     188    //  base.ChangeReference(newParameter, retainData);
     189    //}
    168190  }
    169191
     
    193215      return new ReferenceParameter<T, U>(this, cloner);
    194216    }
     217
     218    // TODO: Remove
     219    //public void ChangeReference(IValueParameter<U> newParameter, bool retainData) {
     220    //  base.ChangeReference(newParameter, retainData);
     221    //}
    195222  }
    196223}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r17680 r17694  
    2121
    2222using System;
    23 using System.ComponentModel;
    2423using System.Drawing;
    2524using System.Linq;
     
    187186    protected override void OnEncodingChanged() {
    188187      base.OnEncodingChanged();
     188      var jobData = (ItemList<Job>)JobData.Clone();
     189      var jobs = Jobs;
     190      var resources = Resources;
    189191      Parameters.Remove(JobDataParameter);
    190192      Parameters.Add(JobDataParameter = new ReferenceParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", Encoding.JobDataParameter));
     
    193195      Parameters.Remove(ResourcesParameter);
    194196      Parameters.Add(ResourcesParameter = new ReferenceParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", Encoding.ResourcesParameter));
     197      JobData = jobData;
     198      Jobs = jobs;
     199      Resources = resources;
     200
     201      RegisterEventHandlers();
    195202    }
    196203
    197204
    198205    private void RegisterEventHandlers() {
    199       JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
    200       JobData.PropertyChanged += JobDataOnPropertyChanged;
    201     }
    202 
    203     private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
    204       JobData.PropertyChanged += JobDataOnPropertyChanged;
     206      ItemListParameterChangeHandler<Job>.Create(JobDataParameter, JobDataOnChanged);
     207    }
     208
     209    private void JobDataOnChanged() {
    205210      Jobs = JobData.Count;
    206     }
    207 
    208     private void JobDataOnPropertyChanged(object sender, PropertyChangedEventArgs e) {
    209       if (e.PropertyName == nameof(JobData.Count)) {
    210         Jobs = JobData.Count;
    211       }
    212     }
     211      Resources = JobData.SelectMany(x => x.Tasks).Select(x => x.ResourceNr).Distinct().Count();
     212    }
     213
    213214
    214215    #region Problem Instance Handling
Note: See TracChangeset for help on using the changeset viewer.