Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/11 18:22:28 (13 years ago)
Author:
cneumuel
Message:

#1215

  • support for maximization problems
  • made base level algorithms stoppable
  • optimization for multiple goals possible (AverageQuality, AverageDeviation, AverageEvaluatedSolutions)
  • lots of fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs

    r6017 r6018  
    9292          if (this.valueConfigurations != null) DeregisterValueConfigurationEvents();
    9393          this.valueConfigurations = value;
     94          KeepActualValueConfigurationIndexConsistent();
    9495          if (this.valueConfigurations != null) RegisterValueConfigurationEvents();
    9596        }
     
    144145      set { autoPopulateValueConfigurations = value; }
    145146    }
    146    
     147
    147148
    148149    #region Constructors and Cloning
     
    258259        } else {
    259260          IItem val;
    260           if (ActualValue.Value != null && ActualValue.ValueDataType == t) {
     261          if (ActualValue.Value != null && ActualValue.Value.GetType() == t) {
    261262            val = (IItem)ActualValue.Value.Clone(); // use existing value for that type (if available)
    262263          } else {
     
    363364    void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    364365      OnToStringChanged();
    365     }
     366      KeepActualValueConfigurationIndexConsistent();
     367    }
     368
    366369    void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    367370      OnToStringChanged();
     371      KeepActualValueConfigurationIndexConsistent();
    368372    }
    369373    void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    370374      OnToStringChanged();
     375      KeepActualValueConfigurationIndexConsistent();
    371376    }
    372377
     
    440445    }
    441446
    442     public string ParameterInfoString {
     447    public virtual string ParameterInfoString {
    443448      get {
    444449        StringBuilder sb = new StringBuilder();
     
    455460          }
    456461
    457           if (this.ActualValue.Value is IParameterizedItem) {
     462          if (this.ValueConfigurations[actualValueConfigurationIndex] is ParameterizedValueConfiguration) {
    458463            string subParams = this.ValueConfigurations[actualValueConfigurationIndex].ParameterInfoString;
    459464            if (!string.IsNullOrEmpty(subParams)) {
     
    583588      }
    584589    }
     590
     591    /// <summary>
     592    /// Ensures that the ActualValueConfigurationIndex has a valid value
     593    /// Only indices of items which are checked are allowed
     594    /// </summary>
     595    private void KeepActualValueConfigurationIndexConsistent() {
     596      if (this.valueConfigurations != null && this.valueConfigurations.CheckedItems.Count() > 0) {
     597        if(this.valueConfigurations.Count <= this.actualValueConfigurationIndex &&
     598           this.valueConfigurations.CheckedItems.Count(x => x.Index == this.actualValueConfigurationIndex) == 1) {
     599          // everything is ok; do nothing
     600        } else {
     601          // current index is invalid, set new one
     602          this.ActualValueConfigurationIndex = this.valueConfigurations.CheckedItems.First().Index;
     603        }
     604      } else {
     605        // no checked valueConfiguration is available; cannot be used
     606        this.ActualValueConfigurationIndex = -1;
     607      }
     608    }
    585609  }
    586610}
Note: See TracChangeset for help on using the changeset viewer.