Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/11 03:53:10 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

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

Legend:

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

    r5338 r5344  
    6666      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>
    6767    </Reference>
     68    <Reference Include="HeuristicLab.Operators-3.3">
     69      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Operators-3.3.dll</HintPath>
     70    </Reference>
    6871    <Reference Include="HeuristicLab.Optimization-3.3">
    6972      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimization-3.3.dll</HintPath>
     
    7477    <Reference Include="HeuristicLab.Optimizer-3.3">
    7578      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Optimizer-3.3.dll</HintPath>
     79    </Reference>
     80    <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     81      <HintPath>..\..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Parameters-3.3.dll</HintPath>
    7682    </Reference>
    7783    <Reference Include="HeuristicLab.Persistence-3.3">
     
    94100  <ItemGroup>
    95101    <Compile Include="AdministratorMenuItem.cs" />
     102    <Compile Include="EmptyAlgorithm.cs" />
     103    <Compile Include="OKBAlgorithm.cs" />
     104    <Compile Include="MultiObjectiveOKBProblem.cs" />
     105    <Compile Include="EmptyMultiObjectiveProblem.cs" />
     106    <Compile Include="EmptyEvaluator.cs" />
     107    <Compile Include="EmptyProblem.cs" />
     108    <Compile Include="EmptyMultiObjectiveEvaluator.cs" />
     109    <Compile Include="EmptySolutionCreator.cs" />
     110    <Compile Include="EmptySingleObjectiveEvaluator.cs" />
     111    <Compile Include="EmptySingleObjectiveProblem.cs" />
    96112    <Compile Include="SingleObjectiveOKBProblem.cs" />
    97113    <Compile Include="OKBProblem.cs" />
     
    184200      <DependentUpon>AlgorithmParameterView.cs</DependentUpon>
    185201    </Compile>
     202    <Compile Include="Views\OKBAlgorithmView.cs">
     203      <SubType>UserControl</SubType>
     204    </Compile>
     205    <Compile Include="Views\OKBAlgorithmView.Designer.cs">
     206      <DependentUpon>OKBAlgorithmView.cs</DependentUpon>
     207    </Compile>
    186208    <Compile Include="Views\OKBProblemView.cs">
    187209      <SubType>UserControl</SubType>
     
    390412    <None Include="HeuristicLab.snk" />
    391413    <None Include="HeuristicLabClientsOKBPlugin.cs.frame" />
    392   </ItemGroup>
    393   <ItemGroup>
    394     <EmbeddedResource Include="Views\OKBProblemView.resx">
    395       <DependentUpon>OKBProblemView.cs</DependentUpon>
    396     </EmbeddedResource>
    397414  </ItemGroup>
    398415  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLabClientsOKBPlugin.cs.frame

    r4943 r5344  
    3737  [PluginDependency("HeuristicLab.MainForm", "3.3")]
    3838  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
     39  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3940  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    4041  [PluginDependency("HeuristicLab.Optimization.Views", "3.3")]
    4142  [PluginDependency("HeuristicLab.Optimizer", "3.3")]
     43  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4244  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    4345  public class HeuristicLabClientsOKBPlugin : PluginBase {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/OKBProblem.cs

    r5338 r5344  
    2424using System.Drawing;
    2525using System.IO;
    26 using System.Linq;
    2726using HeuristicLab.Common;
    2827using HeuristicLab.Core;
     
    3231
    3332namespace HeuristicLab.Clients.OKB {
    34   [Item("OKB Problem", "Represents a problem which is stored in the OKB.")]
     33  [Item("OKB Problem", "A base class for problems which are stored in the OKB.")]
    3534  [StorableClass]
    36   public class OKBProblem : Item, IProblem, IStorableContent {
    37     public string Filename { get; set; }
    38 
    39     public override Image ItemImage {
    40       get { return Problem == null ? HeuristicLab.Common.Resources.VSImageLibrary.Type : Problem.ItemImage; }
    41     }
    42 
    43     public string Name {
    44       get { return Problem == null ? ItemName : Problem.Name; }
    45       set { throw new NotSupportedException("Name cannot be changed."); }
    46     }
    47     public string Description {
    48       get { return Problem == null ? ItemDescription : Problem.Description; }
    49       set { throw new NotSupportedException("Description cannot be changed."); }
    50     }
    51     public bool CanChangeName {
    52       get { return false; }
    53     }
    54     public bool CanChangeDescription {
    55       get { return false; }
    56     }
    57 
    58     public IKeyedItemCollection<string, IParameter> Parameters {
    59       get { return Problem == null ? null : Problem.Parameters; }
    60     }
    61 
     35  public abstract class OKBProblem : Item, IProblem {
    6236    public virtual Type ProblemType {
    6337      get { return typeof(IProblem); }
     
    7145      get { return problem; }
    7246      private set {
    73         if (value == null) throw new ArgumentNullException("Problem");
     47        if (value == null) throw new ArgumentNullException("Problem", "Problem cannot be null.");
    7448        if (value != problem) {
    7549          CancelEventArgs<string> e = new CancelEventArgs<string>(value.Name);
     
    9468    }
    9569
     70    public override Image ItemImage {
     71      get { return Problem.ItemImage; }
     72    }
     73
     74    public string Name {
     75      get { return Problem.Name; }
     76      set { throw new NotSupportedException("Name cannot be changed."); }
     77    }
     78    public string Description {
     79      get { return Problem.Description; }
     80      set { throw new NotSupportedException("Description cannot be changed."); }
     81    }
     82    public bool CanChangeName {
     83      get { return false; }
     84    }
     85    public bool CanChangeDescription {
     86      get { return false; }
     87    }
     88
     89    public IKeyedItemCollection<string, IParameter> Parameters {
     90      get { return Problem.Parameters; }
     91    }
     92
    9693    public IParameter SolutionCreatorParameter {
    97       get { return Problem == null ? null : Problem.SolutionCreatorParameter; }
     94      get { return Problem.SolutionCreatorParameter; }
    9895    }
    9996    public ISolutionCreator SolutionCreator {
    100       get { return Problem == null ? null : Problem.SolutionCreator; }
     97      get { return Problem.SolutionCreator; }
    10198    }
    10299    public IParameter EvaluatorParameter {
    103       get { return Problem == null ? null : Problem.EvaluatorParameter; }
     100      get { return Problem.EvaluatorParameter; }
    104101    }
    105102    public IEvaluator Evaluator {
    106       get { return Problem == null ? null : Problem.Evaluator; }
     103      get { return Problem.Evaluator; }
    107104    }
    108105    public IEnumerable<IOperator> Operators {
    109       get { return Problem == null ? Enumerable.Empty<IOperator>() : Problem.Operators; }
     106      get { return Problem.Operators; }
    110107    }
    111108
     
    118115    [Storable(Name = "Problem")]
    119116    private IProblem StorableProblem {
    120       get { return Problem; }
    121       set { Problem = value; }
     117      get { return problem; }
     118      set {
     119        problem = value;
     120        RegisterProblemEvents();
     121      }
    122122    }
    123123    #endregion
     
    129129      problemId = original.problemId;
    130130      problem = cloner.Clone(original.problem);
    131     }
    132     protected OKBProblem()
     131      RegisterProblemEvents();
     132    }
     133    protected OKBProblem(IProblem initialProblem)
    133134      : base() {
     135      if (initialProblem == null) throw new ArgumentNullException("initialProblem", "Initial problem cannot be null.");
    134136      problemId = -1;
    135     }
    136 
    137     public override IDeepCloneable Clone(Cloner cloner) {
    138       return new OKBProblem(this, cloner);
     137      problem = initialProblem;
     138      RegisterProblemEvents();
    139139    }
    140140
     
    154154
    155155    public void CollectParameterValues(IDictionary<string, IItem> values) {
    156       if (Problem != null) Problem.CollectParameterValues(values);
     156      Problem.CollectParameterValues(values);
    157157    }
    158158
    159159    #region Events
     160    public event EventHandler ProblemChanged;
     161    protected virtual void OnProblemChanged() {
     162      EventHandler handler = ProblemChanged;
     163      if (handler != null) handler(this, EventArgs.Empty);
     164    }
    160165    public event EventHandler<CancelEventArgs<string>> NameChanging;
    161166    protected virtual void OnNameChanging(CancelEventArgs<string> e) {
     
    171176    protected virtual void OnDescriptionChanged() {
    172177      var handler = DescriptionChanged;
    173       if (handler != null) handler(this, EventArgs.Empty);
    174     }
    175     public event EventHandler ProblemChanged;
    176     protected virtual void OnProblemChanged() {
    177       EventHandler handler = ProblemChanged;
    178178      if (handler != null) handler(this, EventArgs.Empty);
    179179    }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/SingleObjectiveOKBProblem.cs

    r5338 r5344  
    3838    }
    3939    public IParameter BestKnownQualityParameter {
    40       get { return Problem == null ? null : Problem.BestKnownQualityParameter; }
     40      get { return Problem.BestKnownQualityParameter; }
     41    }
     42    public IParameter MaximizationParameter {
     43      get { return Problem.MaximizationParameter; }
    4144    }
    4245    public new ISingleObjectiveEvaluator Evaluator {
    43       get { return Problem == null ? null : Problem.Evaluator; }
    44     }
    45     public IParameter MaximizationParameter {
    46       get { return Problem == null ? null : Problem.MaximizationParameter; }
     46      get { return Problem.Evaluator; }
    4747    }
    4848
     
    5050    private SingleObjectiveOKBProblem(bool deserializing) : base(deserializing) { }
    5151    private SingleObjectiveOKBProblem(SingleObjectiveOKBProblem original, Cloner cloner) : base(original, cloner) { }
    52     public SingleObjectiveOKBProblem() : base() { }
     52    public SingleObjectiveOKBProblem() : base(new EmptySingleObjectiveProblem("No problem selected. Please choose a single-objective problem instance from the OKB.")) { }
    5353
    5454    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/OKBProblemView.Designer.cs

    r5338 r5344  
    5959      this.problemLabel.Name = "problemLabel";
    6060      this.problemLabel.Size = new System.Drawing.Size(48, 13);
    61       this.problemLabel.TabIndex = 7;
     61      this.problemLabel.TabIndex = 0;
    6262      this.problemLabel.Text = "&Problem:";
    6363      //
     
    7171      this.problemComboBox.Name = "problemComboBox";
    7272      this.problemComboBox.Size = new System.Drawing.Size(551, 21);
    73       this.problemComboBox.TabIndex = 8;
     73      this.problemComboBox.TabIndex = 1;
    7474      this.problemComboBox.SelectedValueChanged += new System.EventHandler(this.problemComboBox_SelectedValueChanged);
    7575      //
     
    8080      this.refreshButton.Name = "refreshButton";
    8181      this.refreshButton.Size = new System.Drawing.Size(24, 24);
    82       this.refreshButton.TabIndex = 4;
     82      this.refreshButton.TabIndex = 2;
    8383      this.toolTip.SetToolTip(this.refreshButton, "Refresh Problems");
    8484      this.refreshButton.UseVisualStyleBackColor = true;
     
    9797      this.viewHost.ReadOnly = false;
    9898      this.viewHost.Size = new System.Drawing.Size(638, 422);
    99       this.viewHost.TabIndex = 9;
     99      this.viewHost.TabIndex = 3;
    100100      this.viewHost.ViewsLabelVisible = true;
    101101      this.viewHost.ViewType = null;
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Views/OKBProblemView.cs

    r5338 r5344  
    122122    private void problemComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
    123123      Problem problem = problemComboBox.SelectedValue as Problem;
    124       if ((problem != null) && (Content != null)) Content.Load(problem.Id);
     124      if ((problem != null) && (Content != null)) {
     125        Content.Load(problem.Id);
     126        if (Content.ProblemId != problem.Id)  // reset selected item if load was not successful
     127          problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     128      }
    125129    }
    126130    #endregion
Note: See TracChangeset for help on using the changeset viewer.