Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/28/12 15:47:26 (13 years ago)
Author:
spimming
Message:

#1680: merged changes from trunk into branch

Location:
branches/HeuristicLab.Hive.Azure
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs

    r7270 r7669  
    240240    }
    241241
     242    protected override IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IItem value) {
     243      var children = base.GetCollectedValues(value);
     244      foreach (var child in children) {
     245        if (child.Value is IOperator)
     246          yield return new KeyValuePair<string, IItem>(child.Key, new StringValue(((IOperator)child.Value).Name));
     247        else yield return child;
     248      }
     249    }
     250
    242251    #region Events
    243252    public event EventHandler ExecutionStateChanged;
     
    265274      ExecutionState = ExecutionState.Prepared;
    266275      ExecutionTime = TimeSpan.Zero;
    267       foreach (IStatefulItem statefulObject in this.GetObjectGraphObjects().OfType<IStatefulItem>()) {
     276      foreach (IStatefulItem statefulObject in this.GetObjectGraphObjects(new HashSet<string>() { "runs" }).OfType<IStatefulItem>()) {
    268277        statefulObject.InitializeState();
    269278      }
     
    286295    protected virtual void OnStopped() {
    287296      ExecutionState = ExecutionState.Stopped;
    288       foreach (IStatefulItem statefulObject in this.GetObjectGraphObjects().OfType<IStatefulItem>()) {
     297      foreach (IStatefulItem statefulObject in this.GetObjectGraphObjects(new HashSet<string>() { "runs" }).OfType<IStatefulItem>()) {
    289298        statefulObject.ClearState();
    290299      }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/BatchRun.cs

    r7270 r7669  
    339339    private void Optimizer_Paused(object sender, EventArgs e) {
    340340      if (ExecutionState == ExecutionState.Started) {
    341         batchRunStarted = false;
    342         batchRunPaused = true;
    343         batchRunStopped = false;
    344341        OnPaused();
    345342      }
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/Experiment.cs

    r7270 r7669  
    337337    private void optimizer_Prepared(object sender, EventArgs e) {
    338338      if (Optimizers.All(x => x.ExecutionState == ExecutionState.Prepared)) OnPrepared();
    339       else if (Optimizers.All(x => x.ExecutionState != ExecutionState.Started)) OnPaused();
    340339    }
    341340    private void optimizer_Started(object sender, EventArgs e) {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r7270 r7669  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Data;
    2829using HeuristicLab.Parameters;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4445
    4546    [StorableConstructor]
    46     protected Problem(bool deserializing)
    47       : base(deserializing) {
    48       operators = new OperatorCollection(); // operators must never be null
    49     }
     47    protected Problem(bool deserializing) : base(deserializing) { }
    5048    protected Problem(Problem original, Cloner cloner)
    5149      : base(original, cloner) {
    52       operators = cloner.Clone(original.operators);
    5350      RegisterEventHandlers();
    5451    }
     
    5653    protected Problem()
    5754      : base() {
    58       operators = new OperatorCollection();
    59       Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
     55      Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
    6056      OperatorsParameter.Hidden = true;
    6157      RegisterEventHandlers();
     
    6460    [StorableHook(HookType.AfterDeserialization)]
    6561    private void AfterDeserialization() {
    66       // BackwardsCompatibility3.3
    67       #region Backwards compatible code, remove with 3.4
    68       if (!Parameters.ContainsKey(OperatorsParameterName)) {
    69         Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", operators, false));
    70         OperatorsParameter.Hidden = true;
    71       }
    72       #endregion
    7362      RegisterEventHandlers();
    7463    }
     
    8170
    8271    #region properties
    83     private OperatorCollection operators;
     72    // BackwardsCompatibility3.3
     73    #region Backwards compatible code, remove with 3.4
    8474    [Storable(Name = "Operators")]
    8575    private IEnumerable<IOperator> StorableOperators {
    86       get { return operators; }
    87       set { operators = new OperatorCollection(value); }
     76      get { return null; }
     77      set {
     78        if (!Parameters.ContainsKey(OperatorsParameterName)) {
     79          Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(value), false));
     80          OperatorsParameter.Hidden = true;
     81        }
     82      }
    8883    }
     84    #endregion
    8985    protected OperatorCollection Operators {
    90       get { return this.operators; }
     86      get {
     87        // BackwardsCompatibility3.3
     88        #region Backwards compatible code, remove with 3.4
     89        if (!Parameters.ContainsKey(OperatorsParameterName)) {
     90          Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
     91          OperatorsParameter.Hidden = true;
     92        }
     93        #endregion
     94        return OperatorsParameter.Value;
     95      }
    9196    }
    92     IEnumerable<IOperator> IProblem.Operators { get { return operators; } }
     97    IEnumerable<IOperator> IProblem.Operators { get { return Operators; } }
    9398    #endregion
     99
     100    protected override IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IItem value) {
     101      var children = base.GetCollectedValues(value);
     102      foreach (var child in children) {
     103        if (child.Value is IOperator)
     104          yield return new KeyValuePair<string, IItem>(child.Key, new StringValue(((IOperator)child.Value).Name));
     105        else yield return child;
     106      }
     107    }
    94108
    95109    #region events
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs

    r7270 r7669  
    4141      : base() {
    4242      Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
    43       Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
     43      Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
    4444    }
    4545
     
    4747      : base(evaluator, solutionCreator) {
    4848      Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue()));
    49       Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.", new DoubleValue()));
     49      Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem."));
    5050    }
    5151
     
    6868    public BoolValue Maximization {
    6969      get { return MaximizationParameter.Value; }
    70       protected set { MaximizationParameter.Value = value; }
     70      set { MaximizationParameter.Value = value; }
    7171    }
    7272
     
    7979    public DoubleValue BestKnownQuality {
    8080      get { return BestKnownQualityParameter.Value; }
    81       protected set { BestKnownQualityParameter.Value = value; }
     81      set { BestKnownQualityParameter.Value = value; }
    8282    }
    8383
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r7270 r7669  
    121121    [StorableHook(HookType.AfterDeserialization)]
    122122    private void AfterDeserialization() {
    123       AttachEventHandlers();
     123      RegisterEventHandlers();
    124124    }
    125125    public UserDefinedProblem()
     
    132132      Parameters.Add(new ValueParameter<ItemList<IOperator>>("Operators", "The operators that are passed to the algorithm.", new ItemList<IOperator>()));
    133133
    134       AttachEventHandlers();
     134      RegisterEventHandlers();
    135135    }
    136136
    137137    private UserDefinedProblem(UserDefinedProblem original, Cloner cloner)
    138138      : base(original, cloner) {
    139       AttachEventHandlers();
     139      RegisterEventHandlers();
    140140    }
    141141    public override IDeepCloneable Clone(Cloner cloner) {
     
    194194
    195195    #region Helpers
    196     private void AttachEventHandlers() {
     196    private void RegisterEventHandlers() {
    197197      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    198198      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
Note: See TracChangeset for help on using the changeset viewer.