Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11618 for trunk


Ignore:
Timestamp:
12/02/14 11:34:19 (10 years ago)
Author:
mkommend
Message:

#2249: Added fixed value parameter in BestScopeSolutionAnalyzer to enable changing the produced result name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/BestScopeSolutionAnalyzer.cs

    r11615 r11618  
    3838  [StorableClass]
    3939  public class BestScopeSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer {
    40     private const string BestSolutionResultName = "Best Solution";
    4140
    4241    public virtual bool EnabledByDefault {
     
    4948      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    5049    }
     50    public IFixedValueParameter<StringValue> BestSolutionResultNameParameter {
     51      get { return (IFixedValueParameter<StringValue>)Parameters["BestSolution ResultName"]; }
     52    }
    5153    public ILookupParameter<DoubleValue> BestKnownQualityParameter {
    5254      get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     
    5456    public IValueLookupParameter<ResultCollection> ResultsParameter {
    5557      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     58    }
     59
     60    public string BestSolutionResultName {
     61      get { return BestSolutionResultNameParameter.Value.Value; }
     62      set { BestSolutionResultNameParameter.Value.Value = value; }
    5663    }
    5764
     
    6370      return new BestScopeSolutionAnalyzer(this, cloner);
    6471    }
     72
     73    [StorableHook(HookType.AfterDeserialization)]
     74    private void AfterDeserialization() {
     75      if (!Parameters.ContainsKey("BestSolution ResultName"))
     76        Parameters.Add(new FixedValueParameter<StringValue>("BestSolution ResultName", "The name of the result for storing the best solution.", new StringValue("Best Solution")));
     77    }
    6578    #endregion
    6679    public BestScopeSolutionAnalyzer()
     
    6881      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    6982      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the solutions."));
     83      Parameters.Add(new FixedValueParameter<StringValue>("BestSolution ResultName", "The name of the result for storing the best solution.", new StringValue("Best Solution")));
    7084      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution."));
    7185      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the solution should be stored."));
     
    7993
    8094      if (results.ContainsKey(BestSolutionResultName) && !typeof(IScope).IsAssignableFrom(results[BestSolutionResultName].DataType)) {
    81         throw new InvalidOperationException(string.Format("Could not add best solution result, because there is already a result with the name \"{0}\" present in the result collecdtion.", BestSolutionResultName));
     95        throw new InvalidOperationException(string.Format("Could not add best solution result, because there is already a result with the name \"{0}\" present in the result collection.", BestSolutionResultName));
    8296      }
    8397
Note: See TracChangeset for help on using the changeset viewer.