Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5355


Ignore:
Timestamp:
01/22/11 02:38:40 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r5344 r5355  
    100100  <ItemGroup>
    101101    <Compile Include="AdministratorMenuItem.cs" />
     102    <Compile Include="ItemWrapper.cs" />
     103    <Compile Include="NamedItemWrapper.cs" />
     104    <Compile Include="OKBRun.cs" />
    102105    <Compile Include="EmptyAlgorithm.cs" />
    103106    <Compile Include="OKBAlgorithm.cs" />
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/MultiObjectiveOKBProblem.cs

    r5344 r5355  
    3030  [Creatable("Optimization Knowledge Base (OKB)")]
    3131  [StorableClass]
    32   public sealed class MultiObjectiveOKBProblem : OKBProblem, IMultiObjectiveProblem {
     32  public sealed class MultiObjectiveOKBProblem : OKBProblem, IMultiObjectiveProblem, IStorableContent {
     33    public string Filename { get; set; }
     34
    3335    public override Type ProblemType {
    3436      get { return typeof(IMultiObjectiveProblem); }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/OKBAlgorithm.cs

    r5344 r5355  
    2424using System.Drawing;
    2525using System.IO;
     26using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    3435  [Creatable("Optimization Knowledge Base (OKB)")]
    3536  [StorableClass]
    36   public sealed class OKBAlgorithm : Item, IAlgorithm {
     37  public sealed class OKBAlgorithm : Item, IAlgorithm, IStorableContent {
     38    public string Filename { get; set; }
     39
    3740    private long algorithmId;
    3841    public long AlgorithmId {
     
    4851          OnNameChanging(e);
    4952          if (!e.Cancel) {
     53            IProblem problem = algorithm.Problem;
    5054            DeregisterAlgorithmEvents();
    5155            algorithm = value;
     
    5761            OnDescriptionChanged();
    5862            OnAlgorithmChanged();
     63            OnStoreAlgorithmInEachRunChanged();
     64
     65            try {
     66              algorithm.Problem = problem;
     67            }
     68            catch (ArgumentException) {
     69              algorithm.Problem = null;
     70            }
     71            algorithm.Prepare(true);
    5972          }
    6073        }
     
    104117    }
    105118
     119    private int runsCounter;
     120    private RunCollection runs;
    106121    public RunCollection Runs {
    107       get { return Algorithm.Runs; }
     122      get { return runs; }
    108123    }
    109124    public bool StoreAlgorithmInEachRun {
     
    124139        algorithm = value;
    125140        RegisterAlgorithmEvents();
     141      }
     142    }
     143    [Storable(Name = "RunsCounter")]
     144    private int StorableRunsCounter {
     145      get { return runsCounter; }
     146      set { runsCounter = value; }
     147    }
     148    [Storable(Name = "Runs")]
     149    private RunCollection StorableRuns {
     150      get { return runs; }
     151      set {
     152        runs = value;
     153        RegisterRunsEvents();
    126154      }
    127155    }
     
    135163      algorithm = cloner.Clone(original.algorithm);
    136164      RegisterAlgorithmEvents();
     165      runsCounter = original.runsCounter;
     166      runs = cloner.Clone(original.runs);
     167      RegisterRunsEvents();
    137168    }
    138169    public OKBAlgorithm()
     
    141172      algorithm = new EmptyAlgorithm("No algorithm selected. Please choose an algorithm from the OKB.");
    142173      RegisterAlgorithmEvents();
     174      runsCounter = 0;
     175      runs = new RunCollection();
     176      RegisterRunsEvents();
    143177    }
    144178
     
    167201
    168202    public void Prepare() {
    169       Algorithm.Prepare();
     203      Algorithm.Prepare(true);
    170204    }
    171205    public void Prepare(bool clearRuns) {
    172       Algorithm.Prepare(clearRuns);
     206      if (clearRuns) runs.Clear();
     207      Algorithm.Prepare(true);
    173208    }
    174209    public void Start() {
     
    240275    public event EventHandler Stopped;
    241276    private void OnStopped() {
     277      runsCounter++;
     278      runs.Add(new HeuristicLab.Optimization.Run(string.Format("{0} Run {1}", Name, runsCounter), this));
    242279      var handler = Stopped;
    243280      if (handler != null) handler(this, EventArgs.Empty);
     
    328365      OnExceptionOccurred(e.Value);
    329366    }
     367
     368    private void RegisterRunsEvents() {
     369      runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Runs_CollectionReset);
     370    }
     371    private void Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     372      runsCounter = runs.Count;
     373    }
    330374    #endregion
    331375  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/SingleObjectiveOKBProblem.cs

    r5344 r5355  
    3030  [Creatable("Optimization Knowledge Base (OKB)")]
    3131  [StorableClass]
    32   public sealed class SingleObjectiveOKBProblem : OKBProblem, ISingleObjectiveProblem {
     32  public sealed class SingleObjectiveOKBProblem : OKBProblem, ISingleObjectiveProblem, IStorableContent {
     33    public string Filename { get; set; }
     34
    3335    public override Type ProblemType {
    3436      get { return typeof(ISingleObjectiveProblem); }
Note: See TracChangeset for help on using the changeset viewer.