Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/23/20 04:23:45 (4 years ago)
Author:
abeham
Message:

#2521:

  • Changed IParticleCreator to not derive from ISolutionCreator (it calls the solution creator itself, thus leading to an infinite loop)
  • Remove ForceValue method and added method to set value in constrained value parameters from valid values
  • Fix ScopeTreeLookupParameter not caching the actual value
  • Fixed single-objective test functions and removed lots of parameterize code
Location:
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3
Files:
2 edited

Legend:

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

    r17614 r17625  
    5555      set {
    5656        if (ReadOnly) throw new InvalidOperationException("Cannot set the value of a readonly parameter.");
    57         DoSetValue(value);
    58       }
    59     }
    60     public virtual void ForceValue(T value) {
    61       DoSetValue(value);
    62     }
    63     private void DoSetValue(T value) {
    64       if (value != this.value) {
    65         if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
    66         DeregisterValueEvents();
    67         this.value = value;
    68         RegisterValueEvents();
    69         OnValueChanged();
    70       }
    71     }
     57        if (value != this.value) {
     58          if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
     59          DeregisterValueEvents();
     60          this.value = value;
     61          RegisterValueEvents();
     62          OnValueChanged();
     63        }
     64      }
     65    }
     66
    7267    IItem IValueParameter.Value {
    7368      get { return Value; }
     
    170165    #endregion
    171166
    172     public void Populate(IEnumerable<IItem> items) {
     167    public virtual void Populate(IEnumerable<IItem> items) {
    173168      ValidValues.Clear();
    174169      ValidValues.UnionWith(items.OfType<T>());
     
    187182        if (item != null) Value = item;
    188183      }
     184    }
     185
     186    public virtual IItem SetValueToFirstOf(Type itemType) {
     187      var item = ValidValues.Where(i => itemType.IsAssignableFrom(i.GetType())).FirstOrDefault();
     188      if (item != null) Value = item;
     189      return item;
    189190    }
    190191
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ScopeTreeLookupParameter.cs

    r17257 r17625  
    133133        j++;
    134134      }
     135      CachedActualValue = values;
    135136    }
    136137
Note: See TracChangeset for help on using the changeset viewer.