Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/06/10 03:37:29 (14 years ago)
Author:
swagner
Message:

Continued work on algorithm batch processing (#947).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r3274 r3275  
    9090    public abstract ResultCollection Results { get; }
    9191
     92    [Storable]
     93    private RunCollection runs;
     94    public RunCollection Runs {
     95      get { return runs; }
     96    }
     97
    9298    protected Algorithm()
    9399      : base() {
    94100      executionState = ExecutionState.Stopped;
    95101      executionTime = TimeSpan.Zero;
     102      runs = new RunCollection();
    96103    }
    97104    protected Algorithm(string name)
     
    99106      executionState = ExecutionState.Stopped;
    100107      executionTime = TimeSpan.Zero;
     108      runs = new RunCollection();
    101109    }
    102110    protected Algorithm(string name, ParameterCollection parameters)
     
    104112      executionState = ExecutionState.Stopped;
    105113      executionTime = TimeSpan.Zero;
     114      runs = new RunCollection();
    106115    }
    107116    protected Algorithm(string name, string description)
     
    109118      executionState = ExecutionState.Stopped;
    110119      executionTime = TimeSpan.Zero;
     120      runs = new RunCollection();
    111121    }
    112122    protected Algorithm(string name, string description, ParameterCollection parameters)
     
    114124      executionState = ExecutionState.Stopped;
    115125      executionTime = TimeSpan.Zero;
     126      runs = new RunCollection();
    116127    }
    117128
     
    121132      clone.executionTime = executionTime;
    122133      clone.Problem = (IProblem)cloner.Clone(problem);
     134      clone.runs = (RunCollection)cloner.Clone(runs);
    123135      return clone;
    124136    }
    125137
    126     public void Prepare() {
    127       Prepare(true);
    128     }
    129     public virtual void Prepare(bool clearResults) {
     138    public virtual void Prepare() {
    130139      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
    131140        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    132       ExecutionTime = TimeSpan.Zero;
     141    }
     142    public void Prepare(bool clearRuns) {
     143      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
     144        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
     145      if (clearRuns) runs.Clear();
     146      Prepare();
    133147    }
    134148    public virtual void Start() {
     
    172186    public event EventHandler Prepared;
    173187    protected virtual void OnPrepared() {
     188      ExecutionTime = TimeSpan.Zero;
    174189      ExecutionState = ExecutionState.Prepared;
    175190      EventHandler handler = Prepared;
     
    190205    public event EventHandler Stopped;
    191206    protected virtual void OnStopped() {
     207      Run run = new Run("Run (" + ExecutionTime.ToString() + ")");
     208      CollectParameterValues(run.Parameters);
     209      CollectResultValues(run.Results);
     210      runs.Add(run);
    192211      ExecutionState = ExecutionState.Stopped;
    193212      EventHandler handler = Stopped;
Note: See TracChangeset for help on using the changeset viewer.