Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13053


Ignore:
Timestamp:
10/22/15 19:28:06 (9 years ago)
Author:
gkronber
Message:

#2439 merged r12794:12795 and r12797 from trunk to stable

Location:
stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis

  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessBase.cs

    r12009 r13053  
    108108      Parameters[ApproximateGradientsParameterName].Hidden = true; // should not be changed
    109109
     110      // necessary for BFGS
     111      Parameters.Add(new ValueParameter<BoolValue>("Maximization", new BoolValue(false)));
     112      Parameters["Maximization"].Hidden = true;
     113
    110114      var randomCreator = new HeuristicLab.Random.RandomCreator();
    111115      var gpInitializer = new GaussianProcessHyperparameterInitializer();
     
    181185    [StorableHook(HookType.AfterDeserialization)]
    182186    private void AfterDeserialization() {
     187      // BackwardsCompatibility3.4
     188      #region Backwards compatible code, remove with 3.5
     189      if (!Parameters.ContainsKey("Maximization")) {
     190        Parameters.Add(new ValueParameter<BoolValue>("Maximization", new BoolValue(false)));
     191        Parameters["Maximization"].Hidden = true;
     192      }
     193      #endregion
    183194    }
    184195  }
  • stable/HeuristicLab.Algorithms.GradientDescent/3.3/Lbfgs.cs

    r12708 r13053  
    200200        RegisterEvents();
    201201        solutionCreator.OperatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     202        solutionCreator.OperatorParameter.Hidden = true;
    202203        evaluator.OperatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     204        evaluator.OperatorParameter.Hidden = true;
    203205        UpdateAnalyzers();
    204206        ParameterizeOperators();
     
    220222    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
    221223      base.Problem_OperatorsChanged(sender, e);
     224      RegisterEvents();
     225      solutionCreator.OperatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     226      solutionCreator.OperatorParameter.Hidden = true;
     227      evaluator.OperatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     228      evaluator.OperatorParameter.Hidden = true;
    222229      UpdateAnalyzers();
     230      ParameterizeOperators();
    223231    }
    224232
     
    266274        var realVectorParameterName = realVectorCreator.RealVectorParameter.ActualName;
    267275        initializer.PointParameter.ActualName = realVectorParameterName;
     276        initializer.PointParameter.Hidden = true;
    268277        makeStep.PointParameter.ActualName = realVectorParameterName;
     278        makeStep.PointParameter.Hidden = true;
    269279        analyzer.PointParameter.ActualName = realVectorParameterName;
     280        analyzer.PointParameter.Hidden = true;
    270281      }
    271282
    272283      var qualityParameterName = Problem.Evaluator.QualityParameter.ActualName;
    273284      updateResults.QualityParameter.ActualName = qualityParameterName;
     285      updateResults.QualityParameter.Hidden = true;
    274286      analyzer.QualityParameter.ActualName = qualityParameterName;
     287      analyzer.QualityParameter.Hidden = true;
    275288    }
    276289  }
  • stable/HeuristicLab.Algorithms.GradientDescent/3.3/LbfgsUpdateResults.cs

    r12009 r13053  
    3737    private const string StateParameterName = "State";
    3838    private const string ApproximateGradientsParameterName = "ApproximateGradients";
     39    private const string MaximizationParameterName = "Maximization";
    3940
    4041    #region Parameter Properties
     
    5152      get { return (ILookupParameter<LbfgsState>)Parameters[StateParameterName]; }
    5253    }
     54    public ILookupParameter<BoolValue> MaximizationParameter {
     55      get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
     56    }
    5357    #endregion
    5458
     
    5862    private DoubleValue Quality { get { return QualityParameter.ActualValue; } }
    5963    private LbfgsState State { get { return StateParameter.ActualValue; } }
     64
     65    private BoolValue Maximization {
     66      get {
     67        // BackwardsCompatibility3.3
     68        #region Backwards compatible code, remove with 3.4
     69        // the parameter is new, previously we assumed minimization problems
     70        if (MaximizationParameter.ActualValue == null) return new BoolValue(false);
     71        #endregion
     72        return MaximizationParameter.ActualValue;
     73      }
     74    }
     75
    6076    #endregion
    6177
     
    7086      Parameters.Add(new LookupParameter<BoolValue>(ApproximateGradientsParameterName,
    7187                                                    "Flag that indicates if gradients should be approximated."));
     88      Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "Flag that indicates if we solve a maximization problem."));
    7289      // in & out
    7390      Parameters.Add(new LookupParameter<LbfgsState>(StateParameterName, "The state of the LM-BFGS algorithm."));
     91    }
     92
     93    [StorableHook(HookType.AfterDeserialization)]
     94    private void AfterDeserialization() {
     95      // BackwardsCompatibility3.3
     96
     97      #region Backwards compatible code, remove with 3.4
     98      if (!Parameters.ContainsKey(MaximizationParameterName)) {
     99        // previous behaviour defaulted to minimization
     100        Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "Flag that indicates if we solve a maximization problem."));
     101      }
     102      #endregion
    74103    }
    75104
     
    80109    public override IOperation Apply() {
    81110      var state = State;
    82       var f = Quality.Value;
     111      var sign = Maximization.Value ? -1.0 : 1.0;
     112      var f = sign * Quality.Value;
    83113      state.State.f = f;
    84114      if (!ApproximateGradients.Value) {
    85         var g = QualityGradients.ToArray();
     115        var g = QualityGradients.Select(gi => sign * gi).ToArray();
    86116        state.State.g = g;
    87117      }
Note: See TracChangeset for help on using the changeset viewer.