Ignore:
Timestamp:
12/19/18 14:15:49 (3 months ago)
Author:
ddorfmei
Message:

#2931:

  • moved views to separate plugin HeuristicLab.MathematicalOptimization.Views
  • added button in LinearProgrammingProblemView to select the problem definition type
  • added views for problem definitions
  • added ExportFile parameter to LinearProgrammingAlgorithm
  • extended FileValue and FileValueView by the option to save a file
  • code cleanup
File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblem.cs

    r16373 r16405  
    2020#endregion
    2121
    22 using System.Drawing;
     22using System;
    2323using HeuristicLab.Common;
    24 using HeuristicLab.Common.Resources;
    2524using HeuristicLab.Core;
    2625using HeuristicLab.Optimization;
    27 using HeuristicLab.Parameters;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927
    30 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
     28namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
    3129
    3230  [Item("Linear/Mixed Integer Programming Problem (LP/MIP)", "Represents a linear/mixed integer problem.")]
    33   [Creatable(CreatableAttribute.Categories.CombinatorialProblems)]
    3431  [StorableClass]
    35   public class LinearProgrammingProblem : Problem, IProgrammableItem {
     32  public sealed class LinearProgrammingProblem : Problem {
     33    [Storable]
     34    private ILinearProgrammingProblemDefinition problemDefinition;
    3635
    3736    public LinearProgrammingProblem() {
    38       Parameters.Add(new FixedValueParameter<LinearProgrammingProblemDefinitionScript>("ProblemScript",
    39         "Defines the problem.", new LinearProgrammingProblemDefinitionScript { Name = Name }) { GetsCollected = false });
    40       RegisterEvents();
     37      Parameters.Remove(Parameters["Operators"]);
    4138    }
    4239
    43     protected LinearProgrammingProblem(LinearProgrammingProblem original, Cloner cloner)
     40    private LinearProgrammingProblem(LinearProgrammingProblem original, Cloner cloner)
    4441      : base(original, cloner) {
    45       RegisterEvents();
    4642    }
    4743
    4844    [StorableConstructor]
    49     protected LinearProgrammingProblem(bool deserializing) : base(deserializing) { }
    50 
    51     public new static Image StaticItemImage => VSImageLibrary.Script;
    52     public ILinearProgrammingProblemDefinition ProblemDefinition => LinearProgrammingProblemScriptParameter.Value;
    53     public LinearProgrammingProblemDefinitionScript ProblemScript => LinearProgrammingProblemScriptParameter.Value;
    54 
    55     private FixedValueParameter<LinearProgrammingProblemDefinitionScript> LinearProgrammingProblemScriptParameter =>
    56       (FixedValueParameter<LinearProgrammingProblemDefinitionScript>)Parameters["ProblemScript"];
    57 
    58     public override IDeepCloneable Clone(Cloner cloner) {
    59       return new LinearProgrammingProblem(this, cloner);
     45    private LinearProgrammingProblem(bool deserializing) : base(deserializing) {
    6046    }
    6147
    62     protected override void OnNameChanged() {
    63       base.OnNameChanged();
    64       ProblemScript.Name = Name;
     48    public event EventHandler ProblemDefinitionChanged;
     49
     50    public ILinearProgrammingProblemDefinition ProblemDefinition {
     51      get => problemDefinition;
     52      set {
     53        if (problemDefinition == value)
     54          return;
     55        problemDefinition = value;
     56        ProblemDefinitionChanged?.Invoke(this, EventArgs.Empty);
     57      }
    6558    }
     59
     60    public override IDeepCloneable Clone(Cloner cloner) => new LinearProgrammingProblem(this, cloner);
    6661
    6762    [StorableHook(HookType.AfterDeserialization)]
    6863    private void AfterDeserialization() {
    69       RegisterEvents();
    7064    }
    7165
     
    7468      OnReset();
    7569    }
    76 
    77     private void OnProblemScriptNameChanged() {
    78       Name = ProblemScript.Name;
    79     }
    80 
    81     private void RegisterEvents() {
    82       ProblemScript.ProblemDefinitionChanged += (o, e) => OnProblemDefinitionChanged();
    83       ProblemScript.NameChanged += (o, e) => OnProblemScriptNameChanged();
    84     }
    8570  }
    8671}
Note: See TracChangeset for help on using the changeset viewer.