Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/29/19 17:45:06 (6 years ago)
Author:
ddorfmei
Message:

#2931: solved the issues found during the review

Location:
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3
Files:
2 added
6 deleted
26 edited
6 moved

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/HeuristicLab.ExactOptimization-3.3.csproj

    r16581 r16582  
    99    <OutputType>Library</OutputType>
    1010    <AppDesignerFolder>Properties</AppDesignerFolder>
    11     <RootNamespace>HeuristicLab.MathematicalOptimization</RootNamespace>
    12     <AssemblyName>HeuristicLab.MathematicalOptimization-3.3</AssemblyName>
     11    <RootNamespace>HeuristicLab.ExactOptimization</RootNamespace>
     12    <AssemblyName>HeuristicLab.ExactOptimization-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    1414    <FileAlignment>512</FileAlignment>
     
    125125  </ItemGroup>
    126126  <ItemGroup>
     127    <Compile Include="LinearProgramming\Algorithms\ResultStatus.cs" />
    127128    <Compile Include="LinearProgramming\Algorithms\Solvers\BopSolver.cs" />
    128129    <Compile Include="LinearProgramming\Algorithms\Solvers\CoinOrSolver.cs" />
     
    137138    <Compile Include="LinearProgramming\Algorithms\Solvers\ScipSolver.cs" />
    138139    <Compile Include="LinearProgramming\Problems\CompiledProblemDefinition.cs" />
    139     <Compile Include="LinearProgramming\Problems\FileBasedLinearProgrammingProblemDefinition.cs" />
    140     <Compile Include="LinearProgramming\Problems\LinearProgrammingProblem.cs" />
    141     <Compile Include="LinearProgramming\Algorithms\BasisStatus.cs" />
     140    <Compile Include="LinearProgramming\Problems\FileBasedLinearProblemDefinition.cs" />
     141    <Compile Include="LinearProgramming\Problems\LinearProblem.cs" />
    142142    <Compile Include="LinearProgramming\Algorithms\Solvers\CplexSolver.cs" />
    143143    <Compile Include="LinearProgramming\Algorithms\Solvers\GurobiSolver.cs" />
    144144    <Compile Include="LinearProgramming\Algorithms\Solvers\Base\ILinearSolver.cs" />
    145     <Compile Include="LinearProgramming\Algorithms\IncrementalityValues.cs" />
    146     <Compile Include="LinearProgramming\Algorithms\IntegerParam.cs" />
    147     <Compile Include="LinearProgramming\Algorithms\LpAlgorithmValues.cs" />
    148     <Compile Include="LinearProgramming\Problems\ILinearProgrammingProblemDefinition.cs" />
     145    <Compile Include="LinearProgramming\Problems\ILinearProblemDefinition.cs" />
    149146    <Compile Include="LinearProgramming\Algorithms\LinearProgrammingAlgorithm.cs" />
    150147    <Compile Include="LinearProgramming\Algorithms\LinearSolverExtensions.cs" />
    151     <Compile Include="LinearProgramming\Algorithms\OptimizationProblemType.cs" />
    152148    <Compile Include="LinearProgramming\Algorithms\Solvers\Base\LinearSolver.cs" />
    153     <Compile Include="LinearProgramming\Algorithms\DoubleParam.cs" />
     149    <Compile Include="LinearProgramming\Problems\ProgrammableLinearProblemDefinition.cs" />
    154150    <Compile Include="LinearProgramming\Algorithms\ProtoWriteFormat.cs" />
    155     <Compile Include="LinearProgramming\Algorithms\ResultStatus.cs" />
    156     <Compile Include="LinearProgramming\Problems\ProgrammableLinearProgrammingProblemDefinition.cs" />
    157     <Resource Include="LinearProgramming\Templates\CompiledLinearProgrammingProblemDefinition.cs" />
     151    <Compile Include="LinearProgramming\Algorithms\SolverResponseStatus.cs" />
     152    <Resource Include="LinearProgramming\Templates\CompiledLinearProblemDefinition.cs" />
    158153    <Compile Include="LinearProgramming\Templates\ScriptTemplates.Designer.cs">
    159154      <AutoGen>True</AutoGen>
     
    161156      <DependentUpon>ScriptTemplates.resx</DependentUpon>
    162157    </Compile>
    163     <Compile Include="LinearProgramming\Algorithms\SolverResponseStatus.cs" />
    164158    <Compile Include="Properties\AssemblyInfo.cs" />
    165159    <Compile Include="Properties\Settings.Designer.cs">
     
    185179    <EmbeddedResource Include="LinearProgramming\Templates\ScriptTemplates.resx">
    186180      <Generator>ResXFileCodeGenerator</Generator>
     181      <SubType>Designer</SubType>
    187182      <LastGenOutput>ScriptTemplates.Designer.cs</LastGenOutput>
    188       <SubType>Designer</SubType>
    189183    </EmbeddedResource>
    190184  </ItemGroup>
     
    214208      <Name>HeuristicLab.Data-3.3</Name>
    215209    </ProjectReference>
     210    <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
     211      <Project>{DBECB8B0-B166-4133-BAF1-ED67C3FD7FCA}</Project>
     212      <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
     213    </ProjectReference>
    216214    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    217215      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
     
    233231      <Project>{EE07BFF8-B23D-41F5-8AD7-AC9598D7A2C9}</Project>
    234232      <Name>HeuristicLab.Problems.Programmable-3.3</Name>
     233    </ProjectReference>
     234    <ProjectReference Include="..\..\HeuristicLab.Problems.TravelingSalesman\3.3\HeuristicLab.Problems.TravelingSalesman-3.3.csproj">
     235      <Project>{D767C38D-8014-46B0-9A32-03A3AECCE34A}</Project>
     236      <Name>HeuristicLab.Problems.TravelingSalesman-3.3</Name>
    235237    </ProjectReference>
    236238    <ProjectReference Include="..\..\HeuristicLab.Scripting\3.3\HeuristicLab.Scripting-3.3.csproj">
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LinearProgrammingAlgorithm.cs

    r16405 r16582  
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3131
    32 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
    33 
    34   [Item("Linear/Mixed Integer Programming (LP/MIP)", "Linear/mixed integer programming implemented in several solvers. " +
    35     "See also https://dev.heuristiclab.com/trac.fcgi/wiki/Documentation/Howto/LinearMixedIntegerProgramming")] // TODO: update link
     32namespace HeuristicLab.ExactOptimization.LinearProgramming {
     33
     34  [Item("Mixed-Integer Linear Programming (LP, MIP)", "Linear/mixed integer programming implemented in several solvers. " +
     35    "See also https://dev.heuristiclab.com/trac.fcgi/wiki/Documentation/Reference/ExactOptimization")]
    3636  [Creatable(CreatableAttribute.Categories.ExactAlgorithms)]
    3737  [StorableClass]
    38   public class LinearProgrammingAlgorithm : BasicAlgorithm {
     38  public sealed class LinearProgrammingAlgorithm : BasicAlgorithm {
    3939
    4040    [Storable]
     
    4242
    4343    [Storable]
    44     private readonly IFixedValueParameter<FileValue> exportModelParam;
    45 
    46     [Storable]
    47     private readonly IFixedValueParameter<EnumValue<LpAlgorithmValues>> lpAlgorithmParam;
    48 
    49     [Storable]
    5044    private readonly IFixedValueParameter<BoolValue> presolveParam;
    5145
     
    6458    [Storable]
    6559    private IConstrainedValueParameter<ILinearSolver> linearSolverParam;
     60
     61    #region Problem Properties
     62
     63    public new LinearProblem Problem {
     64      get => (LinearProblem)base.Problem;
     65      set => base.Problem = value;
     66    }
     67
     68    public override Type ProblemType { get; } = typeof(LinearProblem);
     69
     70    #endregion
     71    #region Parameter Properties
     72
     73    public IFixedValueParameter<DoubleValue> DualToleranceParameter => dualToleranceParam;
     74    public IConstrainedValueParameter<ILinearSolver> LinearSolverParameter => linearSolverParam;
     75    public IFixedValueParameter<BoolValue> PresolveParameter => presolveParam;
     76    public IFixedValueParameter<DoubleValue> PrimalToleranceParameter => primalToleranceParam;
     77    public IFixedValueParameter<PercentValue> RelativeGapToleranceParameter => relativeGapToleranceParam;
     78    public IFixedValueParameter<BoolValue> ScalingParameter => scalingParam;
     79    public IFixedValueParameter<TimeSpanValue> TimeLimitParameter => timeLimitParam;
     80
     81    #endregion
     82    #region Properties
     83
     84    public double DualTolerance {
     85      get => dualToleranceParam.Value.Value;
     86      set => dualToleranceParam.Value.Value = value;
     87    }
     88
     89    public ILinearSolver LinearSolver {
     90      get => linearSolverParam.Value;
     91      set => linearSolverParam.Value = value;
     92    }
     93
     94    public bool Presolve {
     95      get => presolveParam.Value.Value;
     96      set => presolveParam.Value.Value = value;
     97    }
     98
     99    public double PrimalTolerance {
     100      get => primalToleranceParam.Value.Value;
     101      set => primalToleranceParam.Value.Value = value;
     102    }
     103
     104    public double RelativeGapTolerance {
     105      get => relativeGapToleranceParam.Value.Value;
     106      set => relativeGapToleranceParam.Value.Value = value;
     107    }
     108
     109    public bool Scaling {
     110      get => scalingParam.Value.Value;
     111      set => scalingParam.Value.Value = value;
     112    }
     113
     114    public override bool SupportsPause => LinearSolver.SupportsPause;
     115    public override bool SupportsStop => LinearSolver.SupportsStop;
     116
     117    public TimeSpan TimeLimit {
     118      get => timeLimitParam.Value.Value;
     119      set => timeLimitParam.Value.Value = value;
     120    }
     121
     122    #endregion
    66123
    67124    public LinearProgrammingAlgorithm() {
     
    70127
    71128      ILinearSolver defaultSolver;
    72       linearSolverParam.ValidValues.Add(new BopSolver());
    73129      linearSolverParam.ValidValues.Add(defaultSolver = new CoinOrSolver());
    74130      linearSolverParam.ValidValues.Add(new CplexSolver());
    75131      linearSolverParam.ValidValues.Add(new GlopSolver());
    76       linearSolverParam.ValidValues.Add(new GlpkSolver());
    77132      linearSolverParam.ValidValues.Add(new GurobiSolver());
    78133      linearSolverParam.ValidValues.Add(new ScipSolver());
     
    80135
    81136      Parameters.Add(relativeGapToleranceParam = new FixedValueParameter<PercentValue>(nameof(RelativeGapTolerance),
    82         "Limit for relative MIP gap.", new PercentValue(MPSolverParameters.kDefaultRelativeMipGap)));
     137        "Limit for relative MIP gap.", new PercentValue(SolverParameters.DefaultRelativeMipGap)));
    83138      Parameters.Add(timeLimitParam = new FixedValueParameter<TimeSpanValue>(nameof(TimeLimit),
    84         "Limit for runtime. Set to zero for unlimited runtime.", new TimeSpanValue()));
     139        "Limit for runtime. Set to zero for unlimited runtime.",
     140        new TimeSpanValue(new TimeSpan(0, 1, 0))));
    85141      Parameters.Add(presolveParam =
    86         new FixedValueParameter<BoolValue>(nameof(Presolve), "Advanced usage: presolve mode.", new BoolValue()));
    87       Parameters.Add(lpAlgorithmParam = new FixedValueParameter<EnumValue<LpAlgorithmValues>>(nameof(LpAlgorithm),
    88         "Algorithm to solve linear programs.", new EnumValue<LpAlgorithmValues>(LpAlgorithmValues.DualSimplex)));
     142        new FixedValueParameter<BoolValue>(nameof(Presolve), "Advanced usage: presolve mode.",
     143          new BoolValue(SolverParameters.DefaultPresolve == SolverParameters.PresolveValues.PresolveOn)) { Hidden = true });
    89144      Parameters.Add(dualToleranceParam = new FixedValueParameter<DoubleValue>(nameof(DualTolerance),
    90145        "Advanced usage: tolerance for dual feasibility of basic solutions.",
    91         new DoubleValue(MPSolverParameters.kDefaultDualTolerance)));
     146        new DoubleValue(SolverParameters.DefaultDualTolerance)) { Hidden = true });
    92147      Parameters.Add(primalToleranceParam = new FixedValueParameter<DoubleValue>(nameof(PrimalTolerance),
    93148        "Advanced usage: tolerance for primal feasibility of basic solutions. " +
    94149        "This does not control the integer feasibility tolerance of integer " +
    95150        "solutions for MIP or the tolerance used during presolve.",
    96         new DoubleValue(MPSolverParameters.kDefaultPrimalTolerance)));
     151        new DoubleValue(SolverParameters.DefaultPrimalTolerance)) { Hidden = true });
    97152      Parameters.Add(scalingParam = new FixedValueParameter<BoolValue>(nameof(Scaling),
    98         "Advanced usage: enable or disable matrix scaling.", new BoolValue()));
    99       Parameters.Add(exportModelParam =
    100         new FixedValueParameter<FileValue>(nameof(ExportModel),
    101           "Path of the file the model should be exported to. Run the algorithm to export the model.",
    102           new FileValue {
    103             SaveFile = true,
    104             FileDialogFilter = "CPLEX LP File (*.lp)|*.lp|" +
    105                                "Mathematical Programming System File (*.mps)|*.mps|" +
    106                                "Google OR-Tools Protocol Buffers Text File (*.prototxt)|*.prototxt|" +
    107                                "Google OR-Tools Protocol Buffers Binary File (*.bin)|*.bin"
    108           }));
    109 
    110       Problem = new LinearProgrammingProblem();
     153        "Advanced usage: enable or disable matrix scaling.", new BoolValue()) { Hidden = true });
     154
     155      Problem = new LinearProblem();
    111156    }
    112157
    113158    [StorableConstructor]
    114     protected LinearProgrammingAlgorithm(bool deserializing)
     159    private LinearProgrammingAlgorithm(bool deserializing)
    115160      : base(deserializing) {
    116161    }
    117162
    118     protected LinearProgrammingAlgorithm(LinearProgrammingAlgorithm original, Cloner cloner)
     163    private LinearProgrammingAlgorithm(LinearProgrammingAlgorithm original, Cloner cloner)
    119164      : base(original, cloner) {
    120165      linearSolverParam = cloner.Clone(original.linearSolverParam);
     
    122167      timeLimitParam = cloner.Clone(original.timeLimitParam);
    123168      presolveParam = cloner.Clone(original.presolveParam);
    124       lpAlgorithmParam = cloner.Clone(original.lpAlgorithmParam);
    125169      dualToleranceParam = cloner.Clone(original.dualToleranceParam);
    126170      primalToleranceParam = cloner.Clone(original.primalToleranceParam);
    127171      scalingParam = cloner.Clone(original.scalingParam);
    128       exportModelParam = cloner.Clone(original.exportModelParam);
    129     }
    130 
    131     public double DualTolerance {
    132       get => dualToleranceParam.Value.Value;
    133       set => dualToleranceParam.Value.Value = value;
    134     }
    135 
    136     public string ExportModel {
    137       get => exportModelParam.Value.Value;
    138       set => exportModelParam.Value.Value = value;
    139     }
    140 
    141     public ILinearSolver LinearSolver {
    142       get => linearSolverParam.Value;
    143       set => linearSolverParam.Value = value;
    144     }
    145 
    146     public IConstrainedValueParameter<ILinearSolver> LinearSolverParameter {
    147       get => linearSolverParam;
    148       set => linearSolverParam = value;
    149     }
    150 
    151     public LpAlgorithmValues LpAlgorithm {
    152       get => lpAlgorithmParam.Value.Value;
    153       set => lpAlgorithmParam.Value.Value = value;
    154     }
    155 
    156     public bool Presolve {
    157       get => presolveParam.Value.Value;
    158       set => presolveParam.Value.Value = value;
    159     }
    160 
    161     public double PrimalTolerance {
    162       get => primalToleranceParam.Value.Value;
    163       set => primalToleranceParam.Value.Value = value;
    164     }
    165 
    166     public new LinearProgrammingProblem Problem {
    167       get => (LinearProgrammingProblem)base.Problem;
    168       set => base.Problem = value;
    169     }
    170 
    171     public override Type ProblemType { get; } = typeof(LinearProgrammingProblem);
    172 
    173     public double RelativeGapTolerance {
    174       get => relativeGapToleranceParam.Value.Value;
    175       set => relativeGapToleranceParam.Value.Value = value;
    176     }
    177 
    178     public override ResultCollection Results { get; } = new ResultCollection();
    179 
    180     public bool Scaling {
    181       get => scalingParam.Value.Value;
    182       set => scalingParam.Value.Value = value;
    183     }
    184 
    185     public override bool SupportsPause => LinearSolver.SupportsPause;
    186 
    187     public override bool SupportsStop => LinearSolver.SupportsStop;
    188 
    189     public TimeSpan TimeLimit {
    190       get => timeLimitParam.Value.Value;
    191       set => timeLimitParam.Value.Value = value;
    192172    }
    193173
     
    216196      LinearSolver.PrimalTolerance = PrimalTolerance;
    217197      LinearSolver.DualTolerance = DualTolerance;
    218       LinearSolver.LpAlgorithm = LpAlgorithm;
    219198      LinearSolver.Presolve = Presolve;
    220199      LinearSolver.RelativeGapTolerance = RelativeGapTolerance;
    221200      LinearSolver.Scaling = Scaling;
    222201      LinearSolver.TimeLimit = TimeLimit;
    223       LinearSolver.ExportModel = ExportModel;
    224       var executionTime = ExecutionTime;
    225       ExecutionTimeChanged += (sender, args) => executionTime = ExecutionTime;
    226       LinearSolver.Solve(Problem.ProblemDefinition, ref executionTime, Results, cancellationToken);
     202      LinearSolver.Solve(Problem.ProblemDefinition, Results, cancellationToken);
    227203    }
    228204  }
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LinearSolverExtensions.cs

    r16417 r16582  
    2222using Google.OrTools.LinearSolver;
    2323
    24 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     24namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2525
    2626  public static class LinearSolverExtensions {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProblemType.cs

    r16405 r16582  
    2020#endregion
    2121
    22 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     22namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2323
    2424  public enum ProblemType {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProtoWriteFormat.cs

    r16405 r16582  
    2020#endregion
    2121
    22 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     22namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2323
    2424  public enum ProtoWriteFormat {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/SolverResponseStatus.cs

    r16405 r16582  
    2020#endregion
    2121
    22 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     22using Google.OrTools.LinearSolver;
     23
     24namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2325
    2426  public enum SolverResponseStatus {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalLinearSolver.cs

    r16405 r16582  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     28namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2929
    3030  [StorableClass]
     
    5353    }
    5454
    55     protected override Solver CreateSolver(OptimizationProblemType optimizationProblemType,
     55    public IFixedValueParameter<FileValue> LibraryNameParameter => libraryNameParam;
     56
     57    protected override Solver CreateSolver(Solver.OptimizationProblemType optimizationProblemType,
    5658      string libraryName = null) => base.CreateSolver(optimizationProblemType, LibraryName);
    5759  }
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalLinearSolver.cs

    r16405 r16582  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     28namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2929
    3030  [StorableClass]
     
    5353    }
    5454
    55     protected override Solver CreateSolver(OptimizationProblemType optimizationProblemType,
     55    public IFixedValueParameter<FileValue> LibraryNameParameter => libraryNameParam;
     56
     57    protected override Solver CreateSolver(Solver.OptimizationProblemType optimizationProblemType,
    5658      string libraryName = null) => base.CreateSolver(optimizationProblemType, LibraryName);
    5759  }
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalLinearSolver.cs

    r16405 r16582  
    2020#endregion
    2121
    22 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     22namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2323
    2424  public interface IExternalLinearSolver : ILinearSolver {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalLinearSolver.cs

    r16405 r16582  
    2222using System;
    2323
    24 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     24namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2525
    2626  public interface IIncrementalLinearSolver : ILinearSolver {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ILinearSolver.cs

    r16405 r16582  
    2525using HeuristicLab.Optimization;
    2626
    27 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     27namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2828
    2929  public interface ILinearSolver : IParameterizedNamedItem {
    3030    double DualTolerance { get; set; }
    31 
    32     string ExportModel { get; set; }
    33 
    34     bool Incrementality { get; set; }
    35 
    36     LpAlgorithmValues LpAlgorithm { get; set; }
    3731
    3832    bool Presolve { get; set; }
     
    5650    void Reset();
    5751
    58     void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime, ResultCollection results);
     52    void Solve(ILinearProblemDefinition problemDefintion, ResultCollection results);
    5953
    60     void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime,
     54    void Solve(ILinearProblemDefinition problemDefintion,
    6155      ResultCollection results, CancellationToken cancellationToken);
    6256  }
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalLinearSolver.cs

    r16405 r16582  
    2121
    2222using System;
     23using System.Diagnostics;
    2324using System.Linq;
    2425using System.Threading;
     
    3132using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3233
    33 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     34namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3435
    3536  [StorableClass]
    3637  public class IncrementalLinearSolver : LinearSolver, IIncrementalLinearSolver {
    37     [Storable] protected readonly IValueParameter<TimeSpanValue> qualityUpdateIntervalParam;
    3838
    39     private IndexedDataRow<double> bpcRow;
     39    [Storable]
     40    protected readonly IValueParameter<TimeSpanValue> qualityUpdateIntervalParam;
    4041
    41     private IndexedDataRow<double> qpcRow;
     42    private readonly Stopwatch stopwatch = new Stopwatch();
    4243
    43     [Storable] private IndexedDataTable<double> qualityPerClock;
     44    [Storable]
     45    private TimeSpan executionTime = TimeSpan.Zero;
     46
     47    [Storable]
     48    private IndexedDataTable<double> qualityPerClock;
    4449
    4550    public IncrementalLinearSolver() {
     
    7782    }
    7883
     84    public IValueParameter<TimeSpanValue> QualityUpdateIntervalParameter => qualityUpdateIntervalParam;
     85
    7986    public virtual bool SupportsQualityUpdate => true;
     87
    8088    protected virtual TimeSpan IntermediateTimeLimit => QualityUpdateInterval;
    8189
    82     public override void Solve(ILinearProgrammingProblemDefinition problemDefinition, ref TimeSpan executionTime,
     90    public override void Reset() {
     91      base.Reset();
     92      stopwatch.Reset();
     93      executionTime = TimeSpan.Zero;
     94    }
     95
     96    public override void Solve(ILinearProblemDefinition problemDefinition,
    8397      ResultCollection results, CancellationToken cancellationToken) {
    8498      if (!SupportsQualityUpdate || QualityUpdateInterval == TimeSpan.Zero) {
    85         base.Solve(problemDefinition, ref executionTime, results, cancellationToken);
     99        base.Solve(problemDefinition, results, cancellationToken);
    86100        return;
    87101      }
     
    102116          return;
    103117
     118        stopwatch.Start();
    104119        Solve(problemDefinition, results, IntermediateTimeLimit);
     120        stopwatch.Stop();
     121        executionTime += stopwatch.Elapsed;
    105122        UpdateQuality(results, executionTime);
    106123
     
    120137
    121138    private void UpdateQuality(ResultCollection results, TimeSpan executionTime) {
     139      IndexedDataRow<double> qpcRow;
     140      IndexedDataRow<double> bpcRow;
     141
    122142      if (!results.Exists(r => r.Name == "QualityPerClock")) {
    123143        qualityPerClock = new IndexedDataTable<double>("Quality per Clock");
    124144        qpcRow = new IndexedDataRow<double>("Objective Value");
    125145        bpcRow = new IndexedDataRow<double>("Bound");
     146        qualityPerClock.Rows.Add(qpcRow);
     147        qualityPerClock.Rows.Add(bpcRow);
    126148        results.AddOrUpdateResult("QualityPerClock", qualityPerClock);
     149      } else {
     150        qpcRow = qualityPerClock.Rows["Objective Value"];
     151        bpcRow = qualityPerClock.Rows["Bound"];
    127152      }
    128153
     
    133158
    134159      var objective = ((DoubleValue)results["BestObjectiveValue"].Value).Value;
    135       var bound = solver.IsMIP() ? ((DoubleValue)results["BestObjectiveBound"].Value).Value : double.NaN;
     160      var bound = solver.IsMip() ? ((DoubleValue)results["BestObjectiveBound"].Value).Value : double.NaN;
    136161      var time = executionTime.TotalSeconds;
    137162
     
    140165          qpcRow.Values.Add(Tuple.Create(time, objective));
    141166          qpcRow.Values.Add(Tuple.Create(time, objective));
    142           qualityPerClock.Rows.Add(qpcRow);
    143167          results.AddOrUpdateResult("BestObjectiveValueFoundAt", new TimeSpanValue(TimeSpan.FromSeconds(time)));
    144168        }
     
    152176      }
    153177
    154       if (!solver.IsMIP())
     178      if (!solver.IsMip())
    155179        return;
    156180
     
    159183          bpcRow.Values.Add(Tuple.Create(time, bound));
    160184          bpcRow.Values.Add(Tuple.Create(time, bound));
    161           qualityPerClock.Rows.Add(bpcRow);
    162185        }
    163186      } else {
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/LinearSolver.cs

    r16405 r16582  
    3434using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3535
    36 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     36namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3737
    3838  [StorableClass]
     
    4949    public LinearSolver() {
    5050      Parameters.Add(problemTypeParam =
    51         new ValueParameter<EnumValue<ProblemType>>(nameof(ProblemType), new EnumValue<ProblemType>()));
     51        new ValueParameter<EnumValue<ProblemType>>(nameof(ProblemType),
     52          new EnumValue<ProblemType>(ProblemType.MixedIntegerProgramming)));
    5253      Parameters.Add(solverSpecificParametersParam =
    5354        new FixedValueParameter<TextValue>(nameof(SolverSpecificParameters), new TextValue()));
     
    6566    }
    6667
    67     public double DualTolerance { get; set; } = MPSolverParameters.kDefaultDualTolerance;
    68 
    69     public string ExportModel { get; set; }
     68    public double DualTolerance { get; set; } = SolverParameters.DefaultDualTolerance;
    7069
    7170    public bool Incrementality { get; set; } =
    72           MPSolverParameters.kDefaultIncrementality == MPSolverParameters.INCREMENTALITY_ON;
    73 
    74     public LpAlgorithmValues LpAlgorithm { get; set; }
    75 
    76     public bool Presolve { get; set; } = MPSolverParameters.kDefaultPresolve == MPSolverParameters.PRESOLVE_ON;
    77 
    78     public double PrimalTolerance { get; set; } = MPSolverParameters.kDefaultPrimalTolerance;
     71      SolverParameters.DefaultIncrementality == SolverParameters.IncrementalityValues.IncrementalityOn;
     72
     73    public SolverParameters.LpAlgorithmValues LpAlgorithm { get; set; }
     74    protected virtual Solver.OptimizationProblemType OptimizationProblemType { get; }
     75    public bool Presolve { get; set; } = SolverParameters.DefaultPresolve == SolverParameters.PresolveValues.PresolveOn;
     76    public double PrimalTolerance { get; set; } = SolverParameters.DefaultPrimalTolerance;
    7977
    8078    public ProblemType ProblemType {
     
    8381    }
    8482
    85     public double RelativeGapTolerance { get; set; } = MPSolverParameters.kDefaultRelativeMipGap;
    86 
     83    public IValueParameter<EnumValue<ProblemType>> ProblemTypeParameter => problemTypeParam;
     84    public double RelativeGapTolerance { get; set; } = SolverParameters.DefaultRelativeMipGap;
    8785    public bool Scaling { get; set; }
    8886
     
    9290    }
    9391
     92    public IFixedValueParameter<TextValue> SolverSpecificParametersParameter => solverSpecificParametersParam;
    9493    public virtual bool SupportsPause => true;
    9594    public virtual bool SupportsStop => true;
    9695    public virtual TimeSpan TimeLimit { get; set; } = TimeSpan.Zero;
    97     protected virtual OptimizationProblemType OptimizationProblemType { get; }
    9896
    9997    public override IDeepCloneable Clone(Cloner cloner) => new LinearSolver(this, cloner);
     
    118116
    119117    public bool ExportAsProto(string fileName, ProtoWriteFormat writeFormat = ProtoWriteFormat.ProtoBinary) =>
    120       solver != null && solver.ExportModelAsProtoFormat(fileName, (int)writeFormat);
    121 
    122     public SolverResponseStatus ImportFromMps(string fileName, bool? fixedFormat) => solver == null
    123       ? SolverResponseStatus.Abnormal
    124       : (SolverResponseStatus)solver.ImportModelFromMpsFormat(fileName, fixedFormat.HasValue, fixedFormat ?? false);
    125 
    126     public SolverResponseStatus ImportFromProto(string fileName) => solver == null
    127       ? SolverResponseStatus.Abnormal
    128       : (SolverResponseStatus)solver.ImportModelFromProtoFormat(fileName);
     118      solver != null && solver.ExportModelAsProtoFormat(fileName, (Google.OrTools.LinearSolver.ProtoWriteFormat)writeFormat);
     119
     120    public MPSolverResponseStatus ImportFromMps(string fileName, bool? fixedFormat) =>
     121      solver?.ImportModelFromMpsFormat(fileName, fixedFormat.HasValue, fixedFormat ?? false) ??
     122      (MPSolverResponseStatus)SolverResponseStatus.Abnormal;
     123
     124    public MPSolverResponseStatus ImportFromProto(string fileName) =>
     125      solver?.ImportModelFromProtoFormat(fileName) ?? (MPSolverResponseStatus)SolverResponseStatus.Abnormal;
    129126
    130127    public bool InterruptSolve() => solver?.InterruptSolve() ?? false;
     
    135132    }
    136133
    137     public virtual void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime,
     134    public virtual void Solve(ILinearProblemDefinition problemDefintion,
    138135      ResultCollection results, CancellationToken cancellationToken) =>
    139       Solve(problemDefintion, ref executionTime, results);
    140 
    141     public virtual void Solve(ILinearProgrammingProblemDefinition problemDefinition, ref TimeSpan executionTime,
     136      Solve(problemDefintion, results);
     137
     138    public virtual void Solve(ILinearProblemDefinition problemDefinition,
    142139      ResultCollection results) =>
    143140      Solve(problemDefinition, results, TimeLimit);
    144141
    145     public virtual void Solve(ILinearProgrammingProblemDefinition problemDefinition, ResultCollection results,
     142    public virtual void Solve(ILinearProblemDefinition problemDefinition, ResultCollection results,
    146143      TimeSpan timeLimit) {
    147144      if (solver == null) {
     
    158155      ResultStatus resultStatus;
    159156
    160       using (var parameters = new MPSolverParameters()) {
    161         parameters.SetDoubleParam(MPSolverParameters.RELATIVE_MIP_GAP, RelativeGapTolerance);
    162         parameters.SetDoubleParam(MPSolverParameters.PRIMAL_TOLERANCE, PrimalTolerance);
    163         parameters.SetDoubleParam(MPSolverParameters.DUAL_TOLERANCE, DualTolerance);
    164         parameters.SetIntegerParam(MPSolverParameters.PRESOLVE,
    165           Presolve ? MPSolverParameters.PRESOLVE_ON : MPSolverParameters.PRESOLVE_OFF);
    166         parameters.SetIntegerParam(MPSolverParameters.LP_ALGORITHM, (int)LpAlgorithm);
    167         parameters.SetIntegerParam(MPSolverParameters.INCREMENTALITY,
    168           Incrementality ? MPSolverParameters.INCREMENTALITY_ON : MPSolverParameters.INCREMENTALITY_OFF);
    169         parameters.SetIntegerParam(MPSolverParameters.SCALING,
    170           Scaling ? MPSolverParameters.SCALING_ON : MPSolverParameters.SCALING_OFF);
     157      using (var parameters = new SolverParameters()) {
     158        parameters.SetDoubleParam(SolverParameters.DoubleParam.RelativeMipGap, RelativeGapTolerance);
     159        parameters.SetDoubleParam(SolverParameters.DoubleParam.PrimalTolerance, PrimalTolerance);
     160        parameters.SetDoubleParam(SolverParameters.DoubleParam.DualTolerance, DualTolerance);
     161        parameters.SetIntegerParam(SolverParameters.IntegerParam.Presolve,
     162          (int)(Presolve ? SolverParameters.PresolveValues.PresolveOn : SolverParameters.PresolveValues.PresolveOff));
     163        parameters.SetIntegerParam(SolverParameters.IntegerParam.Incrementality,
     164          (int)(Incrementality ? SolverParameters.IncrementalityValues.IncrementalityOn : SolverParameters.IncrementalityValues.IncrementalityOff));
     165        parameters.SetIntegerParam(SolverParameters.IntegerParam.Scaling,
     166          (int)(Scaling ? SolverParameters.ScalingValues.ScalingOn : SolverParameters.ScalingValues.ScalingOff));
    171167
    172168        if (!solver.SetSolverSpecificParametersAsString(SolverSpecificParameters))
    173169          throw new ArgumentException("Solver specific parameters could not be set.");
    174170
    175         if (!string.IsNullOrWhiteSpace(ExportModel)) {
    176           var fileInfo = new FileInfo(ExportModel);
    177 
    178           if (!fileInfo.Directory?.Exists ?? false) {
    179             Directory.CreateDirectory(fileInfo.Directory.FullName);
    180           }
    181 
    182           bool exportSuccessful;
    183           switch (fileInfo.Extension) {
    184             case ".lp":
    185               exportSuccessful = ExportAsLp(ExportModel);
    186               break;
    187 
    188             case ".mps":
    189               exportSuccessful = ExportAsMps(ExportModel);
    190               break;
    191 
    192             case ".prototxt":
    193               exportSuccessful = ExportAsProto(ExportModel, ProtoWriteFormat.ProtoText);
    194               break;
    195 
    196             case ".bin": // remove file extension as it is added by OR-Tools
    197               exportSuccessful = ExportAsProto(Path.ChangeExtension(ExportModel, null));
    198               break;
    199 
    200             default:
    201               throw new NotSupportedException("File format selected to export model is not supported.");
    202           }
    203         }
    204 
    205         // TODO: show warning if file export didn't work (if exportSuccessful is false)
    206 
    207171        resultStatus = (ResultStatus)solver.Solve(parameters);
    208172      }
     
    211175
    212176      problemDefinition.Analyze(solver, results);
    213       results.AddOrUpdateResult("ResultStatus", new EnumValue<ResultStatus>(resultStatus));
    214       results.AddOrUpdateResult("BestObjectiveValue", new DoubleValue(objectiveValue ?? double.NaN));
    215 
    216       if (solver.IsMIP()) {
     177
     178      if (solver.IsMip()) {
    217179        var objectiveBound = solver.Objective()?.BestBound();
    218180        var absoluteGap = objectiveValue.HasValue && objectiveBound.HasValue
     
    224186          : (double?)null;
    225187
     188        if (resultStatus == ResultStatus.Optimal && absoluteGap.HasValue && !absoluteGap.Value.IsAlmost(0)) {
     189          resultStatus = ResultStatus.OptimalWithinTolerance;
     190        }
     191
    226192        results.AddOrUpdateResult("BestObjectiveBound", new DoubleValue(objectiveBound ?? double.NaN));
    227193        results.AddOrUpdateResult("AbsoluteGap", new DoubleValue(absoluteGap ?? double.NaN));
     
    229195      }
    230196
     197      results.AddOrUpdateResult("ResultStatus", new EnumValue<ResultStatus>(resultStatus));
     198      results.AddOrUpdateResult("BestObjectiveValue", new DoubleValue(objectiveValue ?? double.NaN));
     199
    231200      results.AddOrUpdateResult("NumberOfConstraints", new IntValue(solver.NumConstraints()));
    232201      results.AddOrUpdateResult("NumberOfVariables", new IntValue(solver.NumVariables()));
    233202
    234       if (solver.IsMIP() && solver.Nodes() >= 0) {
     203      if (solver.IsMip() && solver.Nodes() >= 0) {
    235204        results.AddOrUpdateResult(nameof(solver.Nodes), new DoubleValue(solver.Nodes()));
    236205      }
     
    243212    }
    244213
    245     protected virtual Solver CreateSolver(OptimizationProblemType optimizationProblemType, string libraryName = null) {
     214    protected virtual Solver CreateSolver(Solver.OptimizationProblemType optimizationProblemType, string libraryName = null) {
    246215      if (!string.IsNullOrEmpty(libraryName) && !File.Exists(libraryName)) {
    247216        var paths = new List<string> {
     
    256225
    257226      try {
    258         solver = new Solver(Name, (int)optimizationProblemType, libraryName ?? string.Empty);
     227        solver = new Solver(Name, optimizationProblemType, libraryName ?? string.Empty);
    259228      } catch {
    260229        throw new InvalidOperationException($"Could not create {optimizationProblemType}.");
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/BopSolver.cs

    r16405 r16582  
    2121
    2222using System;
     23using Google.OrTools.LinearSolver;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
    29 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     30namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3031
    3132  [Item("BOP", "BOP (https://developers.google.com/optimization/reference/bop/bop_solver/) can be used out of the box.")]
     
    5253    }
    5354
    54     protected override OptimizationProblemType OptimizationProblemType =>
    55                OptimizationProblemType.BopIntegerProgramming;
     55    protected override Solver.OptimizationProblemType OptimizationProblemType =>
     56      Solver.OptimizationProblemType.BopIntegerProgramming;
     57
     58    public override IDeepCloneable Clone(Cloner cloner) => new BopSolver(this, cloner);
    5659  }
    5760}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CoinOrSolver.cs

    r16405 r16582  
    2020#endregion
    2121
    22 using System;
     22using Google.OrTools.LinearSolver;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Optimization;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2726
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     27namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2928
    3029  [Item("Clp/Cbc", "Clp (https://projects.coin-or.org/Clp) and Cbc (https://projects.coin-or.org/Cbc) can be used out of the box.")]
     
    5150    public override bool SupportsStop => false;
    5251
    53     protected override OptimizationProblemType OptimizationProblemType =>
     52    protected override Solver.OptimizationProblemType OptimizationProblemType =>
    5453      ProblemType == ProblemType.LinearProgramming
    55         ? OptimizationProblemType.ClpLinearProgramming
    56         : OptimizationProblemType.CbcMixedIntegerProgramming;
     54        ? Solver.OptimizationProblemType.ClpLinearProgramming
     55        : Solver.OptimizationProblemType.CbcMixedIntegerProgramming;
    5756
    58     public override void Solve(ILinearProgrammingProblemDefinition problemDefinition, ResultCollection results, TimeSpan timeLimit) {
    59       // TODO: warning that solver cannot be stopped or paused
    60       base.Solve(problemDefinition, results, timeLimit);
    61     }
     57    public override IDeepCloneable Clone(Cloner cloner) => new CoinOrSolver(this, cloner);
    6258  }
    6359}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CplexSolver.cs

    r16405 r16582  
    2121
    2222using System;
     23using Google.OrTools.LinearSolver;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
    29 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     30namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3031
    3132  [Item("CPLEX", "CPLEX (https://www.ibm.com/analytics/cplex-optimizer) must be installed and licenced.")]
     
    4041        "# for file format, see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/FileFormats/topics/PRM.html" + Environment.NewLine +
    4142        "# for parameters, see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/introListTopical.html" + Environment.NewLine +
    42         "# example:" + Environment.NewLine +
    43         "# CPXPARAM_RandomSeed 10" + Environment.NewLine;
     43        "# examples:" + Environment.NewLine +
     44        "# CPXPARAM_RandomSeed 10" + Environment.NewLine +
     45        "# CPXPARAM_LPMethod 4 # Barrier (LP)" + Environment.NewLine +
     46        "# CPXPARAM_MIP_Strategy_SubAlgorithm 4 # Barrier (MIP)" + Environment.NewLine +
     47        "# CPXPARAM_MIP_Strategy_Search 2 # Apply dynamic search (MIP)" + Environment.NewLine;
    4448    }
    4549
     
    5357    }
    5458
    55     protected override OptimizationProblemType OptimizationProblemType =>
     59    protected override Solver.OptimizationProblemType OptimizationProblemType =>
    5660      ProblemType == ProblemType.LinearProgramming
    57         ? OptimizationProblemType.CplexLinearProgramming
    58         : OptimizationProblemType.CplexMixedIntegerProgramming;
     61        ? Solver.OptimizationProblemType.CplexLinearProgramming
     62        : Solver.OptimizationProblemType.CplexMixedIntegerProgramming;
     63
     64    public override IDeepCloneable Clone(Cloner cloner) => new CplexSolver(this, cloner);
    5965  }
    6066}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlopSolver.cs

    r16405 r16582  
    2121
    2222using System;
     23using Google.OrTools.LinearSolver;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     29namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2930
    3031  [Item("Glop", "Glop (https://developers.google.com/optimization/lp/glop) can be used out of the box.")]
     
    3738        "# for file format, see Protocol Buffers text format (https://developers.google.com/protocol-buffers/docs/overview#whynotxml)" + Environment.NewLine +
    3839        "# for parameters, see https://github.com/google/or-tools/blob/v6.10/ortools/glop/parameters.proto" + Environment.NewLine +
    39         "# example:" + Environment.NewLine +
    40         "# random_seed: 10" + Environment.NewLine;
     40        "# examples:" + Environment.NewLine +
     41        "# random_seed: 10" + Environment.NewLine +
     42        "# use_dual_simplex: true (LP)" + Environment.NewLine;
    4143    }
    4244
     
    5052    }
    5153
    52     protected override OptimizationProblemType OptimizationProblemType =>
    53       OptimizationProblemType.GlopLinearProgramming;
     54    protected override Solver.OptimizationProblemType OptimizationProblemType =>
     55      Solver.OptimizationProblemType.GlopLinearProgramming;
     56
     57    public override IDeepCloneable Clone(Cloner cloner) => new GlopSolver(this, cloner);
    5458  }
    5559}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlpkSolver.cs

    r16405 r16582  
    2020#endregion
    2121
     22using Google.OrTools.LinearSolver;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     29namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2930
    3031  [Item("GLPK", "GLPK (https://www.gnu.org/software/glpk/) can be used out of the box.")]
     
    4950    public override bool SupportsPause => false;
    5051
    51     protected override OptimizationProblemType OptimizationProblemType =>
     52    protected override Solver.OptimizationProblemType OptimizationProblemType =>
    5253      ProblemType == ProblemType.LinearProgramming
    53         ? OptimizationProblemType.GlpkLinearProgramming
    54         : OptimizationProblemType.GlpkMixedIntegerProgramming;
     54        ? Solver.OptimizationProblemType.GlpkLinearProgramming
     55        : Solver.OptimizationProblemType.GlpkMixedIntegerProgramming;
     56
     57    public override IDeepCloneable Clone(Cloner cloner) => new GlpkSolver(this, cloner);
    5558  }
    5659}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GurobiSolver.cs

    r16405 r16582  
    2121
    2222using System;
     23using Google.OrTools.LinearSolver;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
    29 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     30namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3031
    3132  [Item("Gurobi", "Gurobi (http://www.gurobi.com/) must be installed and licenced.")]
     
    3940        "# for file format, see http://www.gurobi.com/documentation/8.1/refman/prm_format.html" + Environment.NewLine +
    4041        "# for parameters, see http://www.gurobi.com/documentation/8.1/refman/parameters.html" + Environment.NewLine +
    41         "# example:" + Environment.NewLine +
    42         "# Seed 10" + Environment.NewLine;
     42        "# examples:" + Environment.NewLine +
     43        "# Seed 10" + Environment.NewLine +
     44        "# Method 2 # Barrier (LP, root node of MIP)" + Environment.NewLine +
     45        "# NodeMethod 2 # Barrier (MIP)" + Environment.NewLine;
    4346    }
    4447
     
    5356    }
    5457
    55     protected override OptimizationProblemType OptimizationProblemType =>
     58    protected override Solver.OptimizationProblemType OptimizationProblemType =>
    5659      ProblemType == ProblemType.LinearProgramming
    57         ? OptimizationProblemType.GurobiLinearProgramming
    58         : OptimizationProblemType.GurobiMixedIntegerProgramming;
     60        ? Solver.OptimizationProblemType.GurobiLinearProgramming
     61        : Solver.OptimizationProblemType.GurobiMixedIntegerProgramming;
     62
     63    public override IDeepCloneable Clone(Cloner cloner) => new GurobiSolver(this, cloner);
    5964  }
    6065}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/ScipSolver.cs

    r16405 r16582  
    2222using System;
    2323using System.Threading;
     24using Google.OrTools.LinearSolver;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3031
    31 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     32namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3233
    3334  [Item("SCIP", "SCIP (http://scip.zib.de/) must be installed and licenced.")]
     
    4344      SolverSpecificParameters =
    4445        "# for file format and parameters, see https://scip.zib.de/doc/html/PARAMETERS.php" + Environment.NewLine +
    45         "# example:" + Environment.NewLine +
    46         "# branching/random/seed = 10" + Environment.NewLine;
     46        "# examples:" + Environment.NewLine +
     47        "# branching/random/seed = 10" + Environment.NewLine +
     48        "# lp/initalgorithm = b # Barrier (root node of MIP)" + Environment.NewLine +
     49        "# lp/resolvealgorithm = b # Barrier (MIP)" + Environment.NewLine;
    4750    }
    4851
     
    5659    }
    5760
     61    protected override Solver.OptimizationProblemType OptimizationProblemType =>
     62      Solver.OptimizationProblemType.ScipMixedIntegerProgramming;
     63
    5864    protected override TimeSpan IntermediateTimeLimit => timeLimit += QualityUpdateInterval;
    5965
    60     protected override OptimizationProblemType OptimizationProblemType =>
    61           OptimizationProblemType.ScipMixedIntegerProgramming;
     66    public override IDeepCloneable Clone(Cloner cloner) => new ScipSolver(this, cloner);
    6267
    63     public override void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime, ResultCollection results, CancellationToken cancellationToken) {
     68    public override void Solve(ILinearProblemDefinition problemDefintion, ResultCollection results, CancellationToken cancellationToken) {
    6469      timeLimit = TimeSpan.Zero;
    65       base.Solve(problemDefintion, ref executionTime, results, cancellationToken);
     70      base.Solve(problemDefintion, results, cancellationToken);
    6671    }
    6772  }
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/CompiledProblemDefinition.cs

    r16405 r16582  
    2020#endregion
    2121
    22 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     22using HeuristicLab.Common;
     23using HeuristicLab.Core;
    2324
    24   public abstract class CompiledProblemDefinition {
     25namespace HeuristicLab.ExactOptimization.LinearProgramming {
     26
     27  public class CompiledProblemDefinition : Item {
     28
     29    public CompiledProblemDefinition() {
     30    }
     31
     32    protected CompiledProblemDefinition(CompiledProblemDefinition original, Cloner cloner) : base(original, cloner) {
     33    }
     34
    2535    public dynamic vars { get; set; }
    2636
    27     public abstract void Initialize();
     37    public override IDeepCloneable Clone(Cloner cloner) =>
     38      new CompiledProblemDefinition(this, cloner);
     39
     40    public virtual void Initialize() {
     41    }
    2842  }
    2943}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/FileBasedLinearProblemDefinition.cs

    r16581 r16582  
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3232
    33 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     33namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3434
    35   [Item("File-Based Linear/Mixed Integer Programming Problem Definition", "File that defines the model for linear/mixed integer programming problem.")]
     35  [Item("Linear Problem Definition File (MPS, OR-Tools Protocol Buffers Files)", "File that defines the model for linear/mixed integer programming problem.")]
    3636  [StorableClass]
    37   public sealed class FileBasedLinearProgrammingProblemDefinition : ParameterizedNamedItem, ILinearProgrammingProblemDefinition {
     37  public sealed class FileBasedLinearProblemDefinition : ParameterizedNamedItem, ILinearProblemDefinition {
    3838
    3939    [Storable]
     
    4343    private byte[] fileContent;
    4444
    45     public FileBasedLinearProgrammingProblemDefinition() {
     45    public FileBasedLinearProblemDefinition() {
    4646      Parameters.Add(fileNameParam = new FixedValueParameter<FileValue>(nameof(FileName), new FileValue()));
    4747      fileNameParam.Value.FileDialogFilter =
     
    5757    }
    5858
    59     private FileBasedLinearProgrammingProblemDefinition(FileBasedLinearProgrammingProblemDefinition original, Cloner cloner)
     59    private FileBasedLinearProblemDefinition(FileBasedLinearProblemDefinition original, Cloner cloner)
    6060      : base(original, cloner) {
    6161      fileNameParam = cloner.Clone(original.fileNameParam);
     
    6363
    6464    [StorableConstructor]
    65     private FileBasedLinearProgrammingProblemDefinition(bool deserializing) : base(deserializing) { }
     65    private FileBasedLinearProblemDefinition(bool deserializing) : base(deserializing) { }
    6666
    6767    public new static Image StaticItemImage => VSImageLibrary.File;
     
    8080      var fileInfo = new FileInfo(FileName);
    8181      var tempFileName = Path.GetTempFileName();
    82       File.WriteAllBytes(tempFileName, fileContent);
    8382
    84       var status = (SolverResponseStatus)(fileInfo.Extension == ".mps"
    85         ? solver.ImportModelFromMpsFormat(tempFileName)
    86         : solver.ImportModelFromProtoFormat(tempFileName));
     83      try {
     84        File.WriteAllBytes(tempFileName, fileContent);
    8785
    88       if (status == SolverResponseStatus.Abnormal)
    89         throw new FileFormatException($"'{FileName}' is not a valid MPS or Google OR-Tools Protocol Buffers file.");
     86        var status = (SolverResponseStatus)(fileInfo.Extension == ".mps"
     87          ? solver.ImportModelFromMpsFormat(tempFileName)
     88          : solver.ImportModelFromProtoFormat(tempFileName));
    9089
    91       File.Delete(tempFileName);
     90        if (status == SolverResponseStatus.Abnormal)
     91          throw new FileFormatException($"'{FileName}' is not a valid MPS or Google OR-Tools Protocol Buffers file.");
     92      } finally {
     93        File.Delete(tempFileName);
     94      }
    9295    }
    9396
    94     public override IDeepCloneable Clone(Cloner cloner) => new FileBasedLinearProgrammingProblemDefinition(this, cloner);
     97    public override IDeepCloneable Clone(Cloner cloner) => new FileBasedLinearProblemDefinition(this, cloner);
    9598  }
    9699}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ILinearProblemDefinition.cs

    r16581 r16582  
    2121
    2222using Google.OrTools.LinearSolver;
    23 using HeuristicLab.Common;
     23using HeuristicLab.Core;
    2424using HeuristicLab.Optimization;
    2525
    26 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     26namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2727
    28   public interface ILinearProgrammingProblemDefinition : IContent {
     28  public interface ILinearProblemDefinition : IItem {
    2929
    3030    void Analyze(Solver solver, ResultCollection results);
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProblem.cs

    r16581 r16582  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.IO;
     25using System.Linq;
     26using System.Reflection;
     27using Google.OrTools.LinearSolver;
    2328using HeuristicLab.Common;
    2429using HeuristicLab.Core;
     30using HeuristicLab.Data;
    2531using HeuristicLab.Optimization;
     32using HeuristicLab.Parameters;
    2633using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2734
    28 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     35namespace HeuristicLab.ExactOptimization.LinearProgramming {
    2936
    30   [Item("Linear/Mixed Integer Programming Problem (LP/MIP)", "Represents a linear/mixed integer problem.")]
     37  [Item("Mixed-Integer Linear Programming Problem (LP, MIP)", "Represents a linear/mixed integer problem.")]
    3138  [StorableClass]
    32   public sealed class LinearProgrammingProblem : Problem {
     39  public sealed class LinearProblem : Problem, IStorableContent {
     40
    3341    [Storable]
    34     private ILinearProgrammingProblemDefinition problemDefinition;
     42    private readonly IValueParameter<ILinearProblemDefinition> problemDefinitionParam;
    3543
    36     public LinearProgrammingProblem() {
     44    public LinearProblem() {
    3745      Parameters.Remove(Parameters["Operators"]);
     46      Parameters.Add(problemDefinitionParam = new ValueParameter<ILinearProblemDefinition>("Model",
     47        new ProgrammableLinearProblemDefinition(), false));
    3848    }
    3949
    40     private LinearProgrammingProblem(LinearProgrammingProblem original, Cloner cloner)
     50    private LinearProblem(LinearProblem original, Cloner cloner)
    4151      : base(original, cloner) {
     52      problemDefinitionParam = cloner.Clone(original.problemDefinitionParam);
    4253    }
    4354
    4455    [StorableConstructor]
    45     private LinearProgrammingProblem(bool deserializing) : base(deserializing) {
     56    private LinearProblem(bool deserializing) : base(deserializing) {
    4657    }
    4758
    4859    public event EventHandler ProblemDefinitionChanged;
    4960
    50     public ILinearProgrammingProblemDefinition ProblemDefinition {
    51       get => problemDefinition;
     61    public string Filename { get; set; }
     62
     63    public ILinearProblemDefinition ProblemDefinition {
     64      get => problemDefinitionParam.Value;
    5265      set {
    53         if (problemDefinition == value)
     66        if (problemDefinitionParam.Value == value)
    5467          return;
    55         problemDefinition = value;
     68        problemDefinitionParam.Value = value;
    5669        ProblemDefinitionChanged?.Invoke(this, EventArgs.Empty);
    5770      }
    5871    }
    5972
    60     public override IDeepCloneable Clone(Cloner cloner) => new LinearProgrammingProblem(this, cloner);
     73    public IValueParameter<ILinearProblemDefinition> ProblemDefinitionParameter => problemDefinitionParam;
     74
     75    public override IDeepCloneable Clone(Cloner cloner) => new LinearProblem(this, cloner);
     76
     77    public override void CollectParameterValues(IDictionary<string, IItem> values) {
     78      base.CollectParameterValues(values);
     79
     80      if (ProblemDefinition == null) return;
     81
     82      values.Add("Model Type", new StringValue(
     83        (ProblemDefinition.GetType().GetCustomAttributes().Single(a => a is ItemAttribute) as ItemAttribute).Name));
     84
     85      if (ProblemDefinition is ProgrammableLinearProblemDefinition model) {
     86        values.Add("Model Name", new StringValue(model.Name));
     87      }
     88    }
     89
     90    public void ExportModel(string fileName) {
     91      if (string.IsNullOrWhiteSpace(fileName))
     92        throw new ArgumentNullException(nameof(fileName));
     93      if (ProblemDefinition == null)
     94        throw new ArgumentNullException(nameof(ProblemDefinition));
     95
     96      var fileInfo = new FileInfo(fileName);
     97
     98      if (!fileInfo.Directory?.Exists ?? false) {
     99        Directory.CreateDirectory(fileInfo.Directory.FullName);
     100      }
     101
     102      var solver = new Solver(ProblemDefinition.ItemName, Solver.OptimizationProblemType.CbcMixedIntegerProgramming);
     103
     104      ProblemDefinition.BuildModel(solver);
     105
     106      var exportSuccessful = false;
     107      switch (fileInfo.Extension) {
     108        case ".lp":
     109          var lpFormat = solver.ExportModelAsLpFormat(false);
     110          if (!string.IsNullOrEmpty(lpFormat)) {
     111            File.WriteAllText(fileName, lpFormat);
     112            exportSuccessful = true;
     113          }
     114          break;
     115
     116        case ".mps":
     117          var mpsFormat = solver.ExportModelAsMpsFormat(false, false);
     118          if (!string.IsNullOrEmpty(mpsFormat)) {
     119            File.WriteAllText(fileName, mpsFormat);
     120            exportSuccessful = true;
     121          }
     122          break;
     123
     124        case ".prototxt":
     125          exportSuccessful = solver.ExportModelAsProtoFormat(fileName,
     126            (Google.OrTools.LinearSolver.ProtoWriteFormat)ProtoWriteFormat.ProtoText);
     127          break;
     128
     129        case ".bin": // remove file extension as it is added by OR-Tools
     130          fileName = Path.ChangeExtension(fileName, null);
     131          exportSuccessful = solver.ExportModelAsProtoFormat(fileName,
     132            (Google.OrTools.LinearSolver.ProtoWriteFormat)ProtoWriteFormat.ProtoBinary);
     133          break;
     134
     135        default:
     136          throw new NotSupportedException($"File format {fileInfo.Extension} to export model is not supported.");
     137      }
     138
     139      if (!exportSuccessful)
     140        throw new InvalidDataException("Model could not be exported.");
     141    }
    61142
    62143    [StorableHook(HookType.AfterDeserialization)]
    63144    private void AfterDeserialization() {
    64145    }
    65 
    66     private void OnProblemDefinitionChanged() {
    67       OnOperatorsChanged();
    68       OnReset();
    69     }
    70146  }
    71147}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProblemDefinition.cs

    r16581 r16582  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Core;
     28using HeuristicLab.ExactOptimization.LinearProgramming.Templates;
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3132using HeuristicLab.Scripting;
    3233
    33 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     34namespace HeuristicLab.ExactOptimization.LinearProgramming {
    3435
    35   [Item("Programmable Linear/Mixed Integer Programming Problem Definition",
    36     "Script that defines the model and evaluates the solution for a linear/mixed integer programming problem.")]
     36  [Item("Programmable Linear Problem Definition (LP, MIP)",
     37    "Script that defines the model for a linear/mixed integer programming problem.")]
    3738  [StorableClass]
    38   public sealed class ProgrammableLinearProgrammingProblemDefinition : Script, ILinearProgrammingProblemDefinition,
     39  public sealed class ProgrammableLinearProblemDefinition : Script, ILinearProblemDefinition,
    3940    IStorableContent {
    4041    private readonly object compileLock = new object();
    4142
    42     [Storable] private readonly VariableStore variableStore;
     43    [Storable]
     44    private readonly VariableStore variableStore;
    4345
    44     [Storable] private bool codeChanged;
     46    [Storable]
     47    private bool codeChanged;
    4548
    46     private volatile ILinearProgrammingProblemDefinition compiledProblemDefinition;
     49    private volatile ILinearProblemDefinition compiledProblemDefinition;
    4750
    48     public ProgrammableLinearProgrammingProblemDefinition()
    49       : base(ScriptTemplates.CompiledLinearProgrammingProblemDefinition) {
    50       Name = "Programmable Linear/Mixed Integer Programming Problem Definition";
     51    public ProgrammableLinearProblemDefinition()
     52      : base(ScriptTemplates.CompiledLinearProblemDefinition) {
     53      Name = "Programmable Linear Problem Definition";
    5154      variableStore = new VariableStore();
    5255    }
    5356
    5457    [StorableConstructor]
    55     private ProgrammableLinearProgrammingProblemDefinition(bool deserializing) : base(deserializing) {
     58    private ProgrammableLinearProblemDefinition(bool deserializing) : base(deserializing) {
    5659    }
    5760
    58     private ProgrammableLinearProgrammingProblemDefinition(ProgrammableLinearProgrammingProblemDefinition original,
     61    private ProgrammableLinearProblemDefinition(ProgrammableLinearProblemDefinition original,
    5962      Cloner cloner) : base(original, cloner) {
    6063      variableStore = cloner.Clone(original.variableStore);
     
    6871    public VariableStore VariableStore => variableStore;
    6972
    70     private ILinearProgrammingProblemDefinition CompiledProblemDefinition {
     73    private ILinearProblemDefinition CompiledProblemDefinition {
    7174      get {
    7275        // double checked locking pattern
     
    8588    }
    8689
    87     private bool SuppressEvents { get; set; }
    88 
    8990    public void Analyze(Solver solver, ResultCollection results) => CompiledProblemDefinition.Analyze(solver, results);
    9091
     
    9293
    9394    public override IDeepCloneable Clone(Cloner cloner) {
    94       return new ProgrammableLinearProgrammingProblemDefinition(this, cloner);
     95      return new ProgrammableLinearProblemDefinition(this, cloner);
    9596    }
    9697
     
    108109      if (!types.Any(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)))
    109110        throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." + Environment.NewLine +
    110                                                    "The problem definition must be a subclass of CompiledProblemDefinition.");
     111                                                   $"The problem definition must be a subclass of {nameof(CompiledProblemDefinition)} and implement {nameof(ILinearProblemDefinition)}.");
    111112      if (types.Count(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)) > 1)
    112113        throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." + Environment.NewLine +
    113                                                    "Only one subclass of CompiledProblemDefinition is allowed.");
     114                                                   $"Only one subclass of {nameof(CompiledProblemDefinition)} is allowed.");
    114115
    115116      CompiledProblemDefinition inst;
     
    133134
    134135      try {
    135         compiledProblemDefinition = (ILinearProgrammingProblemDefinition)inst;
     136        compiledProblemDefinition = (ILinearProblemDefinition)inst;
    136137        if (fireChanged) OnProblemDefinitionChanged();
    137138      } catch (Exception e) {
     
    139140        throw new ProblemDefinitionScriptException(
    140141          "Using the problem definition in the problem failed." + Environment.NewLine +
    141           "Examine this error message carefully (often there is an issue with the defined encoding).", e);
     142          "Examine this error message carefully.", e);
    142143      }
    143144
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/CompiledLinearProblemDefinition.cs

    r16581 r16582  
    66using HeuristicLab.Core;
    77using HeuristicLab.Data;
     8using HeuristicLab.ExactOptimization.LinearProgramming;
    89using HeuristicLab.Optimization;
    910using Variable = Google.OrTools.LinearSolver.Variable;
    1011
    11 namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
     12public class CompiledLinearProblemDefinition : CompiledProblemDefinition, ILinearProblemDefinition {
     13  private Variable x;
     14  private Variable y;
    1215
    13   public class CompiledLinearProgrammingProblemDefinition : CompiledProblemDefinition, ILinearProgrammingProblemDefinition {
    14     private Variable x;
    15     private Variable y;
     16  public override void Initialize() {
     17    // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
     18    // Add additional initialization code e.g. private variables that you need for evaluating
     19  }
    1620
    17     public override void Initialize() {
    18       // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    19       // Add additional initialization code e.g. private variables that you need for evaluating
    20     }
     21  public void BuildModel(Solver solver) {
     22    // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
     23    // How to define a model using Google OR-Tools: https://developers.google.com/optimization/introduction/cs
     24    // Example model taken from https://developers.google.com/optimization/mip/integer_opt
     25    // Define the decision variables
     26    x = solver.MakeIntVar(0, 3.5, "x");
     27    y = solver.MakeIntVar(0, double.PositiveInfinity, "y");
     28    // Define the constraints
     29    solver.Add(x + 7 * y <= 17.5);
     30    // Define the objective
     31    solver.Maximize(x + 10 * y);
     32  }
    2133
    22     public void BuildModel(Solver solver) {
    23       // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    24       // How to define a model using Google OR-Tools: https://developers.google.com/optimization/introduction/cs
    25       // Example model taken from https://developers.google.com/optimization/mip/integer_opt
    26       // Define the decision variables
    27       x = solver.MakeIntVar(0, 3.5, "x");
    28       y = solver.MakeIntVar(0, double.PositiveInfinity, "y");
    29       // Define the constraints
    30       solver.Add(x + 7 * y <= 17.5);
    31       // Define the objective
    32       solver.Maximize(x + 10 * y);
    33     }
     34  public void Analyze(Solver solver, ResultCollection results) {
     35    // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
     36    // Write or update results given the solution values of the decision variables
     37    results.AddOrUpdateResult("x", new DoubleValue(x.SolutionValue()));
     38    results.AddOrUpdateResult("y", new DoubleValue(y.SolutionValue()));
     39    // The decision variables can also be retrieved from the solver
     40    //results.AddOrUpdateResult("x", new DoubleValue(solver.LookupVariableOrNull("x").SolutionValue()));
     41    //results.AddOrUpdateResult("y", new DoubleValue(solver.LookupVariableOrNull("y").SolutionValue()));
     42  }
    3443
    35     public void Analyze(Solver solver, ResultCollection results) {
    36       // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    37       // Write or update results given the solution values of the decision variables
    38       results.AddOrUpdateResult("x", new DoubleValue(x.SolutionValue()));
    39       results.AddOrUpdateResult("y", new DoubleValue(y.SolutionValue()));
    40       // The decision variables can also be retrieved from the solver
    41       //results.AddOrUpdateResult("x", new DoubleValue(solver.LookupVariableOrNull("x").SolutionValue()));
    42       //results.AddOrUpdateResult("y", new DoubleValue(solver.LookupVariableOrNull("y").SolutionValue()));
    43     }
    44 
    45     // Implement further classes and methods
    46   }
     44  // Implement further classes and methods
    4745}
    4846
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.resx

    r16405 r16582  
    119119  </resheader>
    120120  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    121   <data name="CompiledLinearProgrammingProblemDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms">
    122     <value>compiledlinearprogrammingproblemdefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     121  <data name="CompiledLinearProblemDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms">
     122    <value>compiledlinearproblemdefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    123123  </data>
    124124</root>
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Plugin.cs.frame

    r16405 r16582  
    2222using HeuristicLab.PluginInfrastructure;
    2323
    24 namespace HeuristicLab.MathematicalOptimization {
     24namespace HeuristicLab.ExactOptimization {
    2525
    26   [Plugin("HeuristicLab.MathematicalOptimization", "Provides support for mathematical optimization based on Google OR-Tools. " +
     26  [Plugin("HeuristicLab.ExactOptimization", "Provides support for exact optimization based on Google OR-Tools. " +
    2727    "Requires the Microsoft Visual C++ 2017 Redistributable (x64) - 14.16.27012: https://aka.ms/vs/15/release/vc_redist.x64.exe", "3.3.15.$WCREV$")]
    28   [PluginFile("HeuristicLab.MathematicalOptimization-3.3.dll", PluginFileType.Assembly)]
     28  [PluginFile("HeuristicLab.ExactOptimization-3.3.dll", PluginFileType.Assembly)]
    2929  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
     
    3939  [PluginDependency("HeuristicLab.Problems.Programmable", "3.3")]
    4040  [PluginDependency("HeuristicLab.Scripting", "3.3")]
    41   public class HeuristicLabMathematicalOptimizationPlugin : PluginBase {
     41  public class HeuristicLabExactOptimizationPlugin : PluginBase {
    4242  }
    4343}
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/AssemblyInfo.cs.frame

    r16070 r16582  
    2727// set of attributes. Change these attribute values to modify the information
    2828// associated with an assembly.
    29 [assembly: AssemblyTitle("HeuristiclLab.MathematicalOptimization")]
    30 [assembly: AssemblyDescription("Provides support for mathematical optimization based on Google OR-Tools")]
     29[assembly: AssemblyTitle("HeuristicLab.ExactOptimization")]
     30[assembly: AssemblyDescription("Provides support for exact optimization based on Google OR-Tools")]
    3131[assembly: AssemblyConfiguration("")]
    3232[assembly: AssemblyCompany("HEAL")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2018 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2019 HEAL")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.Designer.cs

    r16405 r16582  
    99//------------------------------------------------------------------------------
    1010
    11 namespace HeuristicLab.MathematicalOptimization.Properties {
     11namespace HeuristicLab.ExactOptimization.Properties {
    1212   
    1313   
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.settings

    r16405 r16582  
    11<?xml version='1.0' encoding='utf-8'?>
    2 <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HeuristicLab.MathematicalOptimization.Properties" GeneratedClassName="Settings">
     2<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HeuristicLab.ExactOptimization.Properties" GeneratedClassName="Settings">
    33  <Profiles />
    44  <Settings>
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/app.config

    r16405 r16582  
    33  <configSections>
    44    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    5       <section name="HeuristicLab.MathematicalOptimization.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
     5      <section name="HeuristicLab.ExactOptimization.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    66    </sectionGroup>
    77  </configSections>
    88  <userSettings>
    9     <HeuristicLab.MathematicalOptimization.Properties.Settings>
     9    <HeuristicLab.ExactOptimization.Properties.Settings>
    1010      <setting name="ScipLibraryName" serializeAs="String">
    1111        <value>scip.dll</value>
     
    2020        <value>gurobi81.dll</value>
    2121      </setting>
    22     </HeuristicLab.MathematicalOptimization.Properties.Settings>
     22    </HeuristicLab.ExactOptimization.Properties.Settings>
    2323  </userSettings>
    2424</configuration>
Note: See TracChangeset for help on using the changeset viewer.