Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/11 18:22:28 (14 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
Location:
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding
Files:
3 edited

Legend:

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

    r5927 r6018  
    1616
    1717    [Storable]
    18     private DoubleValue averageQualityNormalized;
    19     public DoubleValue AverageQualityNormalized {
    20       get { return averageQualityNormalized; }
    21       set {
    22         if (averageQualityNormalized != value) {
    23           averageQualityNormalized = value;
     18    private DoubleValue quality;
     19    public DoubleValue Quality {
     20      get { return quality; }
     21      set {
     22        if (quality != value) {
     23          quality = value;
    2424          OnQualityChanged();
    2525        }
     
    2828
    2929    [Storable]
    30     private DoubleArray qualitiesNormalized;
    31     public DoubleArray QualitiesNormalized {
    32       get { return qualitiesNormalized; }
    33       set {
    34         if (qualitiesNormalized != value) {
    35           qualitiesNormalized = value;
    36         }
    37       }
    38     }
    39 
     30    private DoubleArray normalizedQualityAverages;
     31    public DoubleArray NormalizedQualityAverages {
     32      get { return normalizedQualityAverages; }
     33      set {
     34        if (normalizedQualityAverages != value) {
     35          normalizedQualityAverages = value;
     36        }
     37      }
     38    }
     39
     40    [Storable]
     41    private DoubleArray normalizedQualityDeviations;
     42    public DoubleArray NormalizedQualityDeviations {
     43      get { return normalizedQualityDeviations; }
     44      set {
     45        if (normalizedQualityDeviations != value) {
     46          normalizedQualityDeviations = value;
     47        }
     48      }
     49    }
     50
     51    [Storable]
     52    private DoubleArray normalizedEvaluatedSolutions;
     53    public DoubleArray NormalizedEvaluatedSolutions {
     54      get { return normalizedEvaluatedSolutions; }
     55      set {
     56        if (normalizedEvaluatedSolutions != value) {
     57          normalizedEvaluatedSolutions = value;
     58        }
     59      }
     60    }
     61   
    4062    [Storable]
    4163    private DoubleArray bestQualities;
     
    85107
    86108    [Storable]
     109    private DoubleArray averageEvaluatedSolutions;
     110    public DoubleArray AverageEvaluatedSolutions {
     111      get { return averageEvaluatedSolutions; }
     112      set { averageEvaluatedSolutions = value; }
     113    }
     114
     115    [Storable]
    87116    private IntValue repetitions;
    88117    public IntValue Repetitions {
     
    116145      }
    117146    }
    118 
    119     //[Storable]
    120     //protected string name;
    121     //public string Name {
    122     //  get { return name; }
    123     //  set { name = value; }
    124     //}
    125147
    126148    #region constructors and cloning
     
    136158      algproblemitem.ProblemParameter.Value = problem;
    137159      this.discoverValidValues = false;
    138      
     160
    139161      this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Algorithm", algproblemitem.AlgorithmParameter));
    140162      this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Problem", algproblemitem.ProblemParameter));
     
    145167    protected ParameterConfigurationTree(ParameterConfigurationTree original, Cloner cloner)
    146168      : base(original, cloner) {
    147       this.averageQualityNormalized = cloner.Clone(original.averageQualityNormalized);
    148       this.qualitiesNormalized = cloner.Clone(original.qualitiesNormalized);
     169      this.quality = cloner.Clone(original.quality);
     170      this.normalizedQualityAverages = cloner.Clone(original.normalizedQualityAverages);
     171      this.normalizedQualityDeviations = cloner.Clone(original.normalizedQualityDeviations);
     172      this.normalizedEvaluatedSolutions = cloner.Clone(original.normalizedEvaluatedSolutions);
    149173      this.bestQualities = cloner.Clone(original.BestQualities);
    150174      this.averageQualities = cloner.Clone(original.averageQualities);
     
    153177      this.qualityVariances = cloner.Clone(original.qualityVariances);
    154178      this.averageExecutionTimes = cloner.Clone(original.averageExecutionTimes);
     179      this.averageEvaluatedSolutions = cloner.Clone(original.averageEvaluatedSolutions);
    155180      this.repetitions = cloner.Clone(original.repetitions);
    156181      this.runs = cloner.Clone(original.runs);
     
    171196    public virtual void CollectResultValues(IDictionary<string, IItem> values) {
    172197      values.Add("RunsAverageExecutionTimes", AverageExecutionTimes);
     198      values.Add("RunsAverageEvaluatedSolutions", AverageEvaluatedSolutions);
    173199      values.Add("Repetitions", Repetitions);
    174200      values.Add("RunsBestQualities", BestQualities);
     
    177203      values.Add("RunsQualityVariances", QualityVariances);
    178204      values.Add("RunsQualityStandardDeviations", QualityStandardDeviations);
    179       values.Add("QualitiesNormalized", QualitiesNormalized);
    180       values.Add("AverageQualityNormalized", AverageQualityNormalized);
     205      values.Add("QualitiesNormalized", NormalizedQualityAverages);
     206      values.Add("AverageQualityNormalized", Quality);
    181207      values.Add("Runs", Runs);
    182208    }
     
    209235
    210236      algorithm.CollectParameterValues(this.Parameters);
    211       //((IProblem)ProblemConfiguration.ActualValue.Value).CollectParameterValues(this.Parameters);
    212       //CollectAlgorithmParameterValues((IAlgorithm)AlgorithmConfiguration.ActualValue.Value, parameters);
    213     }
    214 
    215     //protected virtual void CollectAlgorithmParameterValues(IAlgorithm algorithm, IDictionary<string, IItem> values) {
    216     //  var algorithmValues = new Dictionary<string, IItem>();
    217     //  algorithm.CollectParameterValues(algorithmValues);
    218     //  foreach (var value in algorithmValues) {
    219     //    values.Add("Algorithm." + value.Key, value.Value);
    220     //  }
    221     //}
     237    }
    222238
    223239    public Experiment GenerateExperiment(IAlgorithm algorithm, bool createBatchRuns, int repetitions) {
     
    294310        var sb = new StringBuilder();
    295311        if (!string.IsNullOrEmpty(algorithmInfo)) {
    296           sb.Append("Algorithm: ");
     312          sb.Append("Algorithm (");
    297313          sb.Append(algorithmInfo);
     314          sb.Append(")");
    298315        }
    299316        if (!string.IsNullOrEmpty(problemInfo)) {
    300317          if (sb.Length > 0)
    301318            sb.Append(", ");
    302           sb.Append("Problem: ");
     319          sb.Append("Problem( ");
    303320          sb.Append(problemInfo);
     321          sb.Append(")");
    304322        }
    305323        return sb.ToString();
     
    311329      ProblemConfiguration.CollectOptimizedParameterNames(parameterNames, string.Empty);
    312330    }
    313 
    314    
    315331  }
    316332}
  • 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}
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/SingleValuedParameterConfiguration.cs

    r5927 r6018  
    2424      this.discoverValidValues = false;
    2525      this.validValues = new ItemSet<IItem> { valueConfiguration.ActualValue.Value };
    26       this.validTypes = new Type[] {valueConfiguration.ActualValue.ValueDataType};
     26      this.validTypes = new Type[] { valueConfiguration.ActualValue.ValueDataType };
    2727      this.IsNullable = false;
    2828      this.itemImage = valueConfiguration.ItemImage;
     
    6969      OnToStringChanged();
    7070    }
     71
     72    public override string ParameterInfoString {
     73      get {
     74        if (this.Optimize) {
     75          return string.Format("{0} ({1})", this.Name, this.ValueConfigurations.Single().ParameterInfoString);
     76        } else {
     77          return string.Empty;
     78        }
     79      }
     80    }
    7181  }
    7282}
Note: See TracChangeset for help on using the changeset viewer.