Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab 3.3.sln
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab 3.3.sln (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab 3.3.sln (revision 16405)
@@ -50,4 +50,5 @@
{F98A1740-9AC9-4D36-A582-6A2D0D06978D} = {F98A1740-9AC9-4D36-A582-6A2D0D06978D}
{B03C4E41-1D01-4C60-B0F4-DBB257D98CA8} = {B03C4E41-1D01-4C60-B0F4-DBB257D98CA8}
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032} = {D1D69043-17E6-4B8C-BF41-0799C7E56032}
{73F29D43-5714-4069-8FAB-0D18FEB5F175} = {73F29D43-5714-4069-8FAB-0D18FEB5F175}
{3E9E8944-44FF-40BB-A622-3A4A7DD0F198} = {3E9E8944-44FF-40BB-A622-3A4A7DD0F198}
@@ -465,4 +466,6 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathematicalOptimization-3.3", "HeuristicLab.MathematicalOptimization\3.3\HeuristicLab.MathematicalOptimization-3.3.csproj", "{FA3B9270-48B7-4C77-9FEA-2A6EDE82E909}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathematicalOptimization.Views-3.3", "HeuristicLab.MathematicalOptimization.Views\3.3\HeuristicLab.MathematicalOptimization.Views-3.3.csproj", "{D1D69043-17E6-4B8C-BF41-0799C7E56032}"
EndProject
Global
@@ -2264,4 +2267,16 @@
{FA3B9270-48B7-4C77-9FEA-2A6EDE82E909}.Release|x86.ActiveCfg = Release|x86
{FA3B9270-48B7-4C77-9FEA-2A6EDE82E909}.Release|x86.Build.0 = Release|x86
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|x64.ActiveCfg = Debug|x64
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|x64.Build.0 = Debug|x64
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|x86.ActiveCfg = Debug|x86
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Debug|x86.Build.0 = Debug|x86
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x64.ActiveCfg = Release|x64
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x64.Build.0 = Release|x64
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x86.ActiveCfg = Release|x86
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.Designer.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.Designer.cs (revision 16405)
@@ -45,7 +45,9 @@
///
private void InitializeComponent() {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FileValueView));
this.openButton = new System.Windows.Forms.Button();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.stringConvertibleValueView = new HeuristicLab.Data.Views.StringConvertibleValueView();
+ this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.SuspendLayout();
//
@@ -90,4 +92,5 @@
protected System.Windows.Forms.OpenFileDialog openFileDialog;
protected StringConvertibleValueView stringConvertibleValueView;
+ private System.Windows.Forms.SaveFileDialog saveFileDialog;
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs (revision 16405)
@@ -55,7 +55,8 @@
protected virtual void openButton_Click(object sender, EventArgs e) {
- openFileDialog.Filter = Content.FileDialogFilter;
- if (openFileDialog.ShowDialog(this) != DialogResult.OK) return;
- Content.Value = openFileDialog.FileName;
+ var fileDialog = Content.SaveFile ? (FileDialog)saveFileDialog : openFileDialog;
+ fileDialog.Filter = Content.FileDialogFilter;
+ if (fileDialog.ShowDialog(this) != DialogResult.OK) return;
+ Content.Value = fileDialog.FileName;
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/FileValue.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/FileValue.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/FileValue.cs (revision 16405)
@@ -40,4 +40,7 @@
}
+ [Storable]
+ public bool SaveFile { get; set; }
+
[StorableConstructor]
protected FileValue(bool deserializing) : base(deserializing) { }
@@ -45,4 +48,5 @@
: base(original, cloner) {
fileDialogFilter = original.FileDialogFilter;
+ SaveFile = original.SaveFile;
}
public override IDeepCloneable Clone(Cloner cloner) {
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/PathValue.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/PathValue.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.Data/3.3/Path Types/PathValue.cs (revision 16405)
@@ -20,4 +20,5 @@
#endregion
+using System;
using System.IO;
using HeuristicLab.Common;
@@ -29,4 +30,6 @@
[StorableClass]
public abstract class PathValue : Item {
+
+ public EventHandler PathChanged;
[Storable]
@@ -42,4 +45,5 @@
value = value.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
stringValue.Value = value;
+ OnPathChanged();
}
}
@@ -57,4 +61,9 @@
}
+ protected virtual void OnPathChanged() {
+ EventHandler handler = PathChanged;
+ if (handler != null) handler(this, EventArgs.Empty);
+ }
+
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.Designer.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.Designer.cs (revision 16405)
@@ -0,0 +1,78 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+# endregion
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+ partial class FileBasedLinearProgrammingProblemDefinitionView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+ this.SuspendLayout();
+ //
+ // viewHost
+ //
+ this.viewHost.Caption = "View";
+ this.viewHost.Content = null;
+ this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.viewHost.Enabled = false;
+ this.viewHost.Location = new System.Drawing.Point(0, 0);
+ this.viewHost.Name = "viewHost";
+ this.viewHost.ReadOnly = false;
+ this.viewHost.Size = new System.Drawing.Size(150, 150);
+ this.viewHost.TabIndex = 0;
+ this.viewHost.ViewsLabelVisible = true;
+ this.viewHost.ViewType = null;
+ //
+ // LinearProgrammingProblemDefinitionFileView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.viewHost);
+ this.Name = "LinearProgrammingProblemDefinitionFileView";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private MainForm.WindowsForms.ViewHost viewHost;
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/FileBasedLinearProgrammingProblemDefinitionView.cs (revision 16405)
@@ -0,0 +1,54 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Core.Views;
+using HeuristicLab.MainForm;
+using HeuristicLab.MathematicalOptimization.LinearProgramming;
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+
+ [View(nameof(FileBasedLinearProgrammingProblemDefinitionView))]
+ [Content(typeof(FileBasedLinearProgrammingProblemDefinition), IsDefaultView = true)]
+ public partial class FileBasedLinearProgrammingProblemDefinitionView : ItemView {
+
+ public FileBasedLinearProgrammingProblemDefinitionView() {
+ InitializeComponent();
+ }
+
+ public new FileBasedLinearProgrammingProblemDefinition Content {
+ get => (FileBasedLinearProgrammingProblemDefinition)base.Content;
+ set {
+ base.Content = value;
+ OnContentChanged();
+ }
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ if (Content == null) {
+ viewHost.Content = null;
+ } else {
+ viewHost.Content = Content.FileNameParam;
+ Caption = Content.Name;
+ }
+ }
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/HeuristicLab.MathematicalOptimization.Views-3.3.csproj
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/HeuristicLab.MathematicalOptimization.Views-3.3.csproj (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/HeuristicLab.MathematicalOptimization.Views-3.3.csproj (revision 16405)
@@ -0,0 +1,239 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {D1D69043-17E6-4B8C-BF41-0799C7E56032}
+ Library
+ Properties
+ HeuristicLab.MathematicalOptimization.Views
+ HeuristicLab.MathematicalOptimization.Views-3.3
+ v4.6.1
+ 512
+
+
+
+ true
+ full
+ false
+ ..\..\bin\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+ AllRules.ruleset
+ default
+
+
+ pdbonly
+ true
+ ..\..\bin\
+ TRACE
+ prompt
+ 4
+ false
+
+
+ true
+
+
+ HeuristicLab.snk
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ bin\Debug\Plugin.dll.CodeAnalysisLog.xml
+ true
+ GlobalSuppressions.cs
+ prompt
+ MinimumRecommendedRules.ruleset
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
+ false
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
+ false
+ false
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ bin\Release\Plugin.dll.CodeAnalysisLog.xml
+ true
+ GlobalSuppressions.cs
+ prompt
+ MinimumRecommendedRules.ruleset
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
+ true
+ false
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ bin\Debug\Plugin.dll.CodeAnalysisLog.xml
+ true
+ GlobalSuppressions.cs
+ prompt
+ MinimumRecommendedRules.ruleset
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
+ false
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
+ false
+ false
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ bin\Release\Plugin.dll.CodeAnalysisLog.xml
+ true
+ GlobalSuppressions.cs
+ prompt
+ MinimumRecommendedRules.ruleset
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets
+ true
+ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules
+ true
+ false
+ false
+
+
+
+ False
+ ..\..\bin\HeuristicLab.Data-3.3.dll
+
+
+
+
+
+
+
+
+
+
+
+
+ UserControl
+
+
+ FileBasedLinearProgrammingProblemDefinitionView.cs
+
+
+ UserControl
+
+
+ ProgrammableLinearProgrammingProblemDefinitionView.cs
+
+
+ UserControl
+
+
+ LinearProgrammingProblemView.cs
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+ {C38691AE-ECB4-489A-A05D-B035554E0168}
+ HeuristicLab.CodeEditor-3.4
+
+
+ {0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}
+ HeuristicLab.Common.Resources-3.3
+
+
+ {A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}
+ HeuristicLab.Common-3.3
+
+
+ {E226881D-315F-423D-B419-A766FE0D8685}
+ HeuristicLab.Core.Views-3.3
+
+
+ {C36BD924-A541-4A00-AFA8-41701378DDC5}
+ HeuristicLab.Core-3.3
+
+
+ {72104A0B-90E7-42F3-9ABE-9BBBADD4B943}
+ HeuristicLab.Data.Views-3.3
+
+
+ {AB687BBE-1BFE-476B-906D-44237135431D}
+ HeuristicLab.MainForm.WindowsForms-3.3
+
+
+ {3BD61258-31DA-4B09-89C0-4F71FEF5F05A}
+ HeuristicLab.MainForm-3.3
+
+
+ {fa3b9270-48b7-4c77-9fea-2a6ede82e909}
+ HeuristicLab.MathematicalOptimization-3.3
+
+
+ {14AB8D24-25BC-400C-A846-4627AA945192}
+ HeuristicLab.Optimization-3.3
+
+
+ {94186A6A-5176-4402-AE83-886557B53CCA}
+ HeuristicLab.PluginInfrastructure-3.3
+
+
+ {EE07BFF8-B23D-41F5-8AD7-AC9598D7A2C9}
+ HeuristicLab.Problems.Programmable-3.3
+
+
+ {0C2917C8-7AA8-4E18-800A-C4D064F992ED}
+ HeuristicLab.Scripting.Views-3.3
+
+
+ {21977CC3-1757-4B3B-87BD-FF817AAA900F}
+ HeuristicLab.Scripting-3.3
+
+
+
+
+ ProgrammableLinearProgrammingProblemDefinitionView.cs
+
+
+
+
+ set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+set ProjectDir=$(ProjectDir)
+set SolutionDir=$(SolutionDir)
+set Outdir=$(Outdir)
+
+call PreBuildEvent.cmd
+
+
+
+
+
+
+
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.Designer.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.Designer.cs (revision 16405)
@@ -0,0 +1,150 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.ComponentModel;
+using HeuristicLab.Common.Resources;
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+ partial class LinearProgrammingProblemView {
+ ///
+ /// Required designer variable.
+ ///
+ private IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.components = new System.ComponentModel.Container();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LinearProgrammingProblemView));
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.ViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.modelTypeNameLabel = new System.Windows.Forms.Label();
+ this.modelTypeLabel = new System.Windows.Forms.Label();
+ this.changeModelTypeButton = new System.Windows.Forms.Button();
+ this.toolTip = new System.Windows.Forms.ToolTip(this.components);
+ this.panel1.SuspendLayout();
+ this.panel2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this.ViewHost);
+ this.panel1.Controls.Add(this.panel2);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(0, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(300, 150);
+ this.panel1.TabIndex = 7;
+ //
+ // ViewHost
+ //
+ this.ViewHost.Caption = "View";
+ this.ViewHost.Content = null;
+ this.ViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.ViewHost.Enabled = false;
+ this.ViewHost.Location = new System.Drawing.Point(0, 30);
+ this.ViewHost.Name = "ViewHost";
+ this.ViewHost.ReadOnly = false;
+ this.ViewHost.Size = new System.Drawing.Size(300, 120);
+ this.ViewHost.TabIndex = 6;
+ this.ViewHost.ViewsLabelVisible = false;
+ this.ViewHost.ViewType = null;
+ //
+ // panel2
+ //
+ this.panel2.Controls.Add(this.modelTypeNameLabel);
+ this.panel2.Controls.Add(this.modelTypeLabel);
+ this.panel2.Controls.Add(this.changeModelTypeButton);
+ this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
+ this.panel2.Location = new System.Drawing.Point(0, 0);
+ this.panel2.Name = "panel2";
+ this.panel2.Size = new System.Drawing.Size(300, 30);
+ this.panel2.TabIndex = 5;
+ //
+ // modelTypeNameLabel
+ //
+ this.modelTypeNameLabel.AutoSize = true;
+ this.modelTypeNameLabel.Location = new System.Drawing.Point(95, 9);
+ this.modelTypeNameLabel.Name = "modelTypeNameLabel";
+ this.modelTypeNameLabel.Size = new System.Drawing.Size(31, 13);
+ this.modelTypeNameLabel.TabIndex = 6;
+ this.modelTypeNameLabel.Text = "none";
+ //
+ // modelTypeLabel
+ //
+ this.modelTypeLabel.AutoSize = true;
+ this.modelTypeLabel.Location = new System.Drawing.Point(3, 9);
+ this.modelTypeLabel.Name = "modelTypeLabel";
+ this.modelTypeLabel.Size = new System.Drawing.Size(39, 13);
+ this.modelTypeLabel.TabIndex = 5;
+ this.modelTypeLabel.Text = "Model Type:";
+ //
+ // changeModelTypeButton
+ //
+ this.changeModelTypeButton.Image = VSImageLibrary.RefreshDocument;
+ this.changeModelTypeButton.Location = new System.Drawing.Point(68, 3);
+ this.changeModelTypeButton.Name = "changeModelType";
+ this.changeModelTypeButton.Size = new System.Drawing.Size(24, 24);
+ this.changeModelTypeButton.TabIndex = 4;
+ this.toolTip.SetToolTip(this.changeModelTypeButton, "Change Model Type");
+ this.changeModelTypeButton.UseVisualStyleBackColor = true;
+ this.changeModelTypeButton.Click += new System.EventHandler(this.changeModelTypeButton_Click);
+ //
+ // LinearProgrammingProblemView
+ //
+ this.Controls.Add(this.panel1);
+ this.Name = "LinearProgrammingProblemView";
+ this.Size = new System.Drawing.Size(300, 150);
+ this.panel1.ResumeLayout(false);
+ this.panel2.ResumeLayout(false);
+ this.panel2.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel panel1;
+ private MainForm.WindowsForms.ViewHost ViewHost;
+ private System.Windows.Forms.Panel panel2;
+ protected System.Windows.Forms.Button changeModelTypeButton;
+ private System.Windows.Forms.ToolTip toolTip;
+ protected System.Windows.Forms.Button newProblemDefinitionButton;
+ private System.Windows.Forms.Label modelTypeLabel;
+ private System.Windows.Forms.Label modelTypeNameLabel;
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/LinearProgrammingProblemView.cs (revision 16405)
@@ -0,0 +1,113 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Windows.Forms;
+using HeuristicLab.Core.Views;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+using HeuristicLab.MathematicalOptimization.LinearProgramming;
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+
+ [View(nameof(LinearProgrammingProblemView))]
+ [Content(typeof(LinearProgrammingProblem), true)]
+ public partial class LinearProgrammingProblemView : ItemView {
+ protected ViewHost definitionView;
+
+ private TypeSelectorDialog problemTypeSelectorDialog;
+
+ public LinearProgrammingProblemView() {
+ InitializeComponent();
+ definitionView = ViewHost;
+ }
+
+ public new LinearProgrammingProblem Content {
+ get => (LinearProgrammingProblem)base.Content;
+ set => base.Content = value;
+ }
+
+ protected override void DeregisterContentEvents() {
+ base.DeregisterContentEvents();
+ Content.ProblemDefinitionChanged -= ContentOnProblemDefinitionChanged;
+ Content.NameChanged -= ContentOnNameChanged;
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ if (Content == null) {
+ definitionView.Content = null;
+ } else {
+ Caption = Content.Name;
+ ContentOnProblemDefinitionChanged(Content, EventArgs.Empty);
+ }
+ }
+
+ protected override void RegisterContentEvents() {
+ Content.ProblemDefinitionChanged += ContentOnProblemDefinitionChanged;
+ Content.NameChanged += ContentOnNameChanged;
+ base.RegisterContentEvents();
+ }
+
+ private void changeModelTypeButton_Click(object sender, EventArgs e) {
+ if (problemTypeSelectorDialog == null) {
+ problemTypeSelectorDialog = new TypeSelectorDialog { Caption = "Select Model Type" };
+ problemTypeSelectorDialog.TypeSelector.Caption = "Available Model Types";
+ problemTypeSelectorDialog.TypeSelector.Configure(typeof(ILinearProgrammingProblemDefinition), false, true);
+ }
+ if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
+ try {
+ Content.ProblemDefinition =
+ (ILinearProgrammingProblemDefinition)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
+ } catch (Exception ex) {
+ ErrorHandling.ShowErrorDialog(this, ex);
+ }
+ }
+ }
+
+ private void ContentOnNameChanged(object sender, EventArgs eventArgs) {
+ Caption = Content.Name;
+ }
+
+ private void ContentOnProblemDefinitionChanged(object sender, EventArgs eventArgs) {
+ var problemDefinition = ((LinearProgrammingProblem)sender).ProblemDefinition;
+ definitionView.Content = problemDefinition;
+
+ switch (problemDefinition) {
+ case null:
+ modelTypeNameLabel.Text = "none";
+ break;
+
+ case ProgrammableLinearProgrammingProblemDefinition _:
+ modelTypeNameLabel.Text = "Script";
+ break;
+
+ case FileBasedLinearProgrammingProblemDefinition _:
+ modelTypeNameLabel.Text = "File";
+ break;
+
+ default:
+ throw new NotImplementedException("Unknown problem definition type.");
+ }
+ }
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs (revision 16405)
@@ -0,0 +1,42 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.MathematicalOptimization {
+
+ [Plugin("HeuristicLab.MathematicalOptimization.Views", "Views for mathematical optimization", "3.3.15.0")]
+ [PluginFile("HeuristicLab.MathematicalOptimization.Views-3.3.dll", PluginFileType.Assembly)]
+ [PluginDependency("HeuristicLab.CodeEditor", "3.4")]
+ [PluginDependency("HeuristicLab.Common", "3.3")]
+ [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
+ [PluginDependency("HeuristicLab.Core", "3.3")]
+ [PluginDependency("HeuristicLab.Core.Views", "3.3")]
+ [PluginDependency("HeuristicLab.Data", "3.3")]
+ [PluginDependency("HeuristicLab.MainForm", "3.3")]
+ [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
+ [PluginDependency("HeuristicLab.MathematicalOptimization", "3.3")]
+ [PluginDependency("HeuristicLab.Problems.Programmable", "3.3")]
+ [PluginDependency("HeuristicLab.Scripting", "3.3")]
+ [PluginDependency("HeuristicLab.Scripting.Views", "3.3")]
+ public class HeuristicLabMathematicalOptimizationViewsPlugin : PluginBase {
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs.frame
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs.frame (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Plugin.cs.frame (revision 16405)
@@ -0,0 +1,42 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.PluginInfrastructure;
+
+namespace HeuristicLab.MathematicalOptimization {
+
+ [Plugin("HeuristicLab.MathematicalOptimization.Views", "Views for mathematical optimization", "3.3.15.$WCREV$")]
+ [PluginFile("HeuristicLab.MathematicalOptimization.Views-3.3.dll", PluginFileType.Assembly)]
+ [PluginDependency("HeuristicLab.CodeEditor", "3.4")]
+ [PluginDependency("HeuristicLab.Common", "3.3")]
+ [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
+ [PluginDependency("HeuristicLab.Core", "3.3")]
+ [PluginDependency("HeuristicLab.Core.Views", "3.3")]
+ [PluginDependency("HeuristicLab.Data", "3.3")]
+ [PluginDependency("HeuristicLab.MainForm", "3.3")]
+ [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
+ [PluginDependency("HeuristicLab.MathematicalOptimization", "3.3")]
+ [PluginDependency("HeuristicLab.Problems.Programmable", "3.3")]
+ [PluginDependency("HeuristicLab.Scripting", "3.3")]
+ [PluginDependency("HeuristicLab.Scripting.Views", "3.3")]
+ public class HeuristicLabMathematicalOptimizationViewsPlugin : PluginBase {
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.Designer.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.Designer.cs (revision 16405)
@@ -0,0 +1,189 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+
+using System.ComponentModel;
+using System.Windows.Forms;
+using HeuristicLab.Scripting.Views;
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+ partial class ProgrammableLinearProgrammingProblemDefinitionView {
+ ///
+ /// Required designer variable.
+ ///
+ private IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgrammableLinearProgrammingProblemDefinitionView));
+ this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+ this.variableStoreView = new HeuristicLab.Scripting.Views.VariableStoreView();
+ this.infoTabControl.SuspendLayout();
+ this.outputTabPage.SuspendLayout();
+ this.errorListTabPage.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
+ this.splitContainer1.Panel1.SuspendLayout();
+ this.splitContainer1.Panel2.SuspendLayout();
+ this.splitContainer1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
+ this.splitContainer2.Panel1.SuspendLayout();
+ this.splitContainer2.Panel2.SuspendLayout();
+ this.splitContainer2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // compileButton
+ //
+ this.toolTip.SetToolTip(this.compileButton, "Compile (F6)");
+ //
+ // imageList
+ //
+ this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
+ this.imageList.Images.SetKeyName(0, "");
+ this.imageList.Images.SetKeyName(1, "");
+ //
+ // infoTabControl
+ //
+ this.infoTabControl.Size = new System.Drawing.Size(593, 113);
+ //
+ // outputTabPage
+ //
+ this.outputTabPage.Size = new System.Drawing.Size(585, 87);
+ //
+ // outputTextBox
+ //
+ this.outputTextBox.Size = new System.Drawing.Size(579, 81);
+ //
+ // errorListTabPage
+ //
+ this.errorListTabPage.Size = new System.Drawing.Size(585, 87);
+ //
+ // errorListView
+ //
+ this.errorListView.Size = new System.Drawing.Size(579, 81);
+ //
+ // codeEditor
+ //
+ this.codeEditor.Size = new System.Drawing.Size(593, 429);
+ //
+ // splitContainer1
+ //
+ this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
+ this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer1.Size = new System.Drawing.Size(593, 546);
+ this.splitContainer1.SplitterDistance = 429;
+ //
+ // nameTextBox
+ //
+ this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
+ this.errorProvider.SetIconPadding(this.nameTextBox, 2);
+ this.nameTextBox.Location = new System.Drawing.Point(68, 0);
+ this.nameTextBox.Size = new System.Drawing.Size(742, 20);
+ //
+ // infoLabel
+ //
+ this.infoLabel.Location = new System.Drawing.Point(816, 3);
+ //
+ // splitContainer2
+ //
+ this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+ this.splitContainer2.Location = new System.Drawing.Point(6, 56);
+ this.splitContainer2.Name = "splitContainer2";
+ //
+ // splitContainer2.Panel1
+ //
+ this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
+ //
+ // splitContainer2.Panel2
+ //
+ this.splitContainer2.Panel2.Controls.Add(this.variableStoreView);
+ this.splitContainer2.Size = new System.Drawing.Size(826, 546);
+ this.splitContainer2.SplitterDistance = 593;
+ this.splitContainer2.TabIndex = 10;
+ //
+ // variableStoreView
+ //
+ this.variableStoreView.Caption = "ItemCollection View";
+ this.variableStoreView.Content = null;
+ this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.variableStoreView.Location = new System.Drawing.Point(0, 0);
+ this.variableStoreView.Name = "variableStoreView";
+ this.variableStoreView.ReadOnly = false;
+ this.variableStoreView.Size = new System.Drawing.Size(229, 546);
+ this.variableStoreView.TabIndex = 10;
+ //
+ // LinearProgrammingProblemDefinitionScriptView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.splitContainer2);
+ this.Name = "LinearProgrammingProblemDefinitionScriptView";
+ this.Controls.SetChildIndex(this.infoTextLabel, 0);
+ this.Controls.SetChildIndex(this.compileButton, 0);
+ this.Controls.SetChildIndex(this.splitContainer2, 0);
+ this.Controls.SetChildIndex(this.nameLabel, 0);
+ this.Controls.SetChildIndex(this.nameTextBox, 0);
+ this.Controls.SetChildIndex(this.infoLabel, 0);
+ this.infoTabControl.ResumeLayout(false);
+ this.outputTabPage.ResumeLayout(false);
+ this.outputTabPage.PerformLayout();
+ this.errorListTabPage.ResumeLayout(false);
+ this.splitContainer1.Panel1.ResumeLayout(false);
+ this.splitContainer1.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
+ this.splitContainer1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+ this.splitContainer2.Panel1.ResumeLayout(false);
+ this.splitContainer2.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
+ this.splitContainer2.ResumeLayout(false);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private SplitContainer splitContainer2;
+ private VariableStoreView variableStoreView;
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.cs (revision 16405)
@@ -0,0 +1,70 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Drawing;
+using HeuristicLab.MainForm;
+using HeuristicLab.MathematicalOptimization.LinearProgramming;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.Programmable;
+using HeuristicLab.Scripting.Views;
+
+namespace HeuristicLab.MathematicalOptimization.Views {
+
+ [View(nameof(ProgrammableLinearProgrammingProblemDefinitionView))]
+ [Content(typeof(ProgrammableLinearProgrammingProblemDefinition), IsDefaultView = true)]
+ public partial class ProgrammableLinearProgrammingProblemDefinitionView : ScriptView {
+
+ public ProgrammableLinearProgrammingProblemDefinitionView() {
+ InitializeComponent();
+ }
+
+ public new ProgrammableLinearProgrammingProblemDefinition Content {
+ get => (ProgrammableLinearProgrammingProblemDefinition)base.Content;
+ set => base.Content = value;
+ }
+
+ public override bool Compile() {
+ try {
+ base.Compile();
+ } catch (ProblemDefinitionScriptException e) {
+ ErrorHandling.ShowErrorDialog(e);
+ return false;
+ }
+ return true;
+ }
+
+ protected override void Content_CodeChanged(object sender, EventArgs e) {
+ base.Content_CodeChanged(sender, e);
+ UpdateInfoTextLabel("Code changed, compilation necessary!", Color.Red);
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ variableStoreView.Content = Content?.VariableStore;
+ }
+
+ protected override void SetEnabledStateOfControls() {
+ base.SetEnabledStateOfControls();
+ variableStoreView.Enabled = Content != null && !Locked && !ReadOnly;
+ }
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.resx
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.resx (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/ProgrammableLinearProgrammingProblemDefinitionView.resx (revision 16405)
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 243, 17
+
+
+ 17, 17
+
+
+
+ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
+ LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
+ ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACG
+ CQAAAk1TRnQBSQFMAgEBAgEAAQgBAAEIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
+ AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
+ AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
+ AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
+ AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
+ AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
+ ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
+ AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
+ AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
+ AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
+ AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
+ AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
+ AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
+ AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
+ AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
+ ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
+ Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
+ AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
+ AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
+ AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
+ ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
+ Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
+ AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
+ AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
+ AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
+ AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
+ AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
+ AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/0EAAXQHSwUqAikBmQQA
+ ARoBbwFFAUQCIwFLARokAAFLAqAB5QN6A1kBWAM3ATEBSwIAAfQBdAFFAUYEJQEkASMBbwH0IgABGgGZ
+ AqAB5QF6AXkBFAERAVgBWQFYAjcBMQGZAgABkwFMAUYCJgJNASYCJQEjAW8jAAF5A6AB5QF5ARIBFQFR
+ AlkBWAE3AUsCAAEaAW8BTAJNAeMC/wF1ASYCJQEjARoiAAH0AXkDoAF5AXMBUQF5AlkBWAExAfMCAAGZ
+ AUwDTQF1Av8B4wImASUBJAFLIwABeQGaAqABmgEUAUoBeQF6AVkBWAFzAwABdAVNAnUBTQMmASUBIyMA
+ Af8BeQKgARwBEgFDAXkCegFSAfYDAAGTBOMBdQL/Ak0CJgElASMkAAGZAXkBoALrARQBSgF6AVgBmQQA
+ AZMEdQGUAv8BdQFNAiYBJQFEJAAB/wF5AaABEgHsAW0BDgF6AVEB/wQAAZMEdQG9Av8BmgFNAiYBJQFF
+ JQABGwF5AesB7wHsAQ8BWAEaBQABmQGTA5QBvQL/Ab0CTQEmAUYBbyYAAXkBmQHrARIBeQFSBgABGgGT
+ AZQBmgGUAZoC/wGUAk0BRgFFARomAAHzAXkBoAF6AVgB9AcAARoBkwKUAnUB4wJNAkwBdCgAAXkBmQF5
+ ARwIAAH0ARoCkwJ1AeMBTQFMAW8BdAH0KAAB9gFSAUsB/woAARoEkwF0Am9kAAFCAU0BPgcAAT4DAAEo
+ AwABQAMAARADAAEBAQABAQUAAYAXAAP/AQAE/wYAAfABDwYAAcABAwYAAcABAwQAAYABAQGAAQEEAAGA
+ AQEBgAEBBAABwAEDAYABAQQAAcABAwGAAQEEAAHgAQcBgAEBBAAB4AEHAYABAQQAAfABDwGAAQEEAAH4
+ AR8BgAEBBAAB+AEfAcABAwQAAfwBPwHAAQMEAAH8AT8B8AEPBAAE/wQACw==
+
+
+
+ 120, 17
+
+
+ 243, 17
+
+
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs (revision 16405)
@@ -0,0 +1,57 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristiclLab.MathematicalOptimization.Views")]
+[assembly: AssemblyDescription("Views for mathematical optimization")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("HEAL")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2018 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("78D3CF45-1EDF-4AF1-B215-EA196A9EC7B1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("3.3.0.0")]
+[assembly: AssemblyFileVersion("3.3.15.0")]
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs.frame
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs.frame (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/Properties/AssemblyInfo.cs.frame (revision 16405)
@@ -0,0 +1,57 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HeuristiclLab.MathematicalOptimization.Views")]
+[assembly: AssemblyDescription("Views for mathematical optimization")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("HEAL")]
+[assembly: AssemblyProduct("HeuristicLab")]
+[assembly: AssemblyCopyright("(c) 2002-2018 HEAL")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("78D3CF45-1EDF-4AF1-B215-EA196A9EC7B1")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("3.3.0.0")]
+[assembly: AssemblyFileVersion("3.3.15.$WCREV$")]
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/app.config
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/app.config (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization.Views/3.3/app.config (revision 16405)
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+ scip.dll
+
+
+ gurobi81.dll
+
+
+ cplex1280.dll
+
+
+ glpk_4_65.dll
+
+
+
+
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/HeuristicLab.MathematicalOptimization-3.3.csproj
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/HeuristicLab.MathematicalOptimization-3.3.csproj (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/HeuristicLab.MathematicalOptimization-3.3.csproj (revision 16405)
@@ -121,54 +121,39 @@
-
-
-
+
-
+
-
-
-
-
+
+
+
+
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
- UserControl
-
-
- LinearProgrammingProblemDefinitionScriptView.cs
-
-
-
-
- UserControl
-
-
- LinearProgrammingProblemView.cs
-
-
-
+
+
+
+
+
+
+
+
True
@@ -176,5 +161,5 @@
ScriptTemplates.resx
-
+
@@ -201,7 +186,5 @@
ResXFileCodeGenerator
ScriptTemplates.Designer.cs
-
-
- LinearProgrammingProblemView.cs
+ Designer
@@ -211,8 +194,4 @@
HeuristicLab.Analysis-3.3
-
- {C38691AE-ECB4-489A-A05D-B035554E0168}
- HeuristicLab.CodeEditor-3.4
-
{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}
@@ -227,8 +206,4 @@
HeuristicLab.Common-3.3
-
- {E226881D-315F-423D-B419-A766FE0D8685}
- HeuristicLab.Core.Views-3.3
-
{C36BD924-A541-4A00-AFA8-41701378DDC5}
@@ -239,12 +214,4 @@
HeuristicLab.Data-3.3
-
- {AB687BBE-1BFE-476B-906D-44237135431D}
- HeuristicLab.MainForm.WindowsForms-3.3
-
-
- {3BD61258-31DA-4B09-89C0-4F71FEF5F05A}
- HeuristicLab.MainForm-3.3
-
{14AB8D24-25BC-400C-A846-4627AA945192}
@@ -266,8 +233,4 @@
{EE07BFF8-B23D-41F5-8AD7-AC9598D7A2C9}
HeuristicLab.Problems.Programmable-3.3
-
-
- {0C2917C8-7AA8-4E18-800A-C4D064F992ED}
- HeuristicLab.Scripting.Views-3.3
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/DoubleParam.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/DoubleParam.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/DoubleParam.cs (revision 16405)
@@ -0,0 +1,39 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ // Enumeration of parameters that take continuous values.
+ public enum DoubleParam {
+
+ // Limit for relative MIP gap.
+ RelativeMipGap = 0,
+
+ // Advanced usage: tolerance for primal feasibility of basic
+ // solutions. This does not control the integer feasibility
+ // tolerance of integer solutions for MIP or the tolerance used
+ // during presolve.
+ PrimalTolerance = 1,
+
+ // Advanced usage: tolerance for dual feasibility of basic solutions.
+ DualTolerance = 2
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IncrementalityValues.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IncrementalityValues.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IncrementalityValues.cs (revision 16405)
@@ -0,0 +1,32 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public enum IncrementalityValues {
+
+ // Start solve from scratch.
+ IncrementalityOff = 0,
+
+ // Reuse results from previous solve as much as the underlying solver allows.
+ IncrementalityOn = 1
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IntegerParam.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IntegerParam.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/IntegerParam.cs (revision 16405)
@@ -0,0 +1,39 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms {
+
+ // Enumeration of parameters that take integer or categorical values.
+ public enum IntegerParam {
+
+ // Advanced usage: presolve mode.
+ Presolve = 1000,
+
+ // Algorithm to solve linear programs.
+ LpAlgorithm = 1001,
+
+ // Advanced usage: incrementality from one solve to the next.
+ Incrementality = 1002,
+
+ // Advanced usage: enable or disable matrix scaling.
+ Scaling = 1003
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LinearProgrammingAlgorithm.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LinearProgrammingAlgorithm.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LinearProgrammingAlgorithm.cs (revision 16405)
@@ -26,12 +26,9 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("Linear/Mixed Integer Programming (LP/MIP)", "Linear/mixed integer programming implemented in several solvers. " +
@@ -45,4 +42,7 @@
[Storable]
+ private readonly IFixedValueParameter exportModelParam;
+
+ [Storable]
private readonly IFixedValueParameter> lpAlgorithmParam;
@@ -60,27 +60,22 @@
[Storable]
- private IConstrainedValueParameter solverParam;
-
- [Storable]
private readonly IFixedValueParameter timeLimitParam;
- public IConstrainedValueParameter SolverParameter {
- get => solverParam;
- set => solverParam = value;
- }
+ [Storable]
+ private IConstrainedValueParameter linearSolverParam;
public LinearProgrammingAlgorithm() {
- Parameters.Add(solverParam =
- new ConstrainedValueParameter(nameof(Solver), "The solver used to solve the model."));
-
- ISolver defaultSolver;
- solverParam.ValidValues.Add(new BopSolver());
- solverParam.ValidValues.Add(defaultSolver = new CoinOrSolver());
- solverParam.ValidValues.Add(new CplexSolver());
- solverParam.ValidValues.Add(new GlopSolver());
- solverParam.ValidValues.Add(new GlpkSolver());
- solverParam.ValidValues.Add(new GurobiSolver());
- solverParam.ValidValues.Add(new ScipSolver());
- solverParam.Value = defaultSolver;
+ Parameters.Add(linearSolverParam =
+ new ConstrainedValueParameter(nameof(LinearSolver), "The solver used to solve the model."));
+
+ ILinearSolver defaultSolver;
+ linearSolverParam.ValidValues.Add(new BopSolver());
+ linearSolverParam.ValidValues.Add(defaultSolver = new CoinOrSolver());
+ linearSolverParam.ValidValues.Add(new CplexSolver());
+ linearSolverParam.ValidValues.Add(new GlopSolver());
+ linearSolverParam.ValidValues.Add(new GlpkSolver());
+ linearSolverParam.ValidValues.Add(new GurobiSolver());
+ linearSolverParam.ValidValues.Add(new ScipSolver());
+ linearSolverParam.Value = defaultSolver;
Parameters.Add(relativeGapToleranceParam = new FixedValueParameter(nameof(RelativeGapTolerance),
@@ -102,4 +97,14 @@
Parameters.Add(scalingParam = new FixedValueParameter(nameof(Scaling),
"Advanced usage: enable or disable matrix scaling.", new BoolValue()));
+ Parameters.Add(exportModelParam =
+ new FixedValueParameter(nameof(ExportModel),
+ "Path of the file the model should be exported to. Run the algorithm to export the model.",
+ new FileValue {
+ SaveFile = true,
+ FileDialogFilter = "CPLEX LP File (*.lp)|*.lp|" +
+ "Mathematical Programming System File (*.mps)|*.mps|" +
+ "Google OR-Tools Protocol Buffers Text File (*.prototxt)|*.prototxt|" +
+ "Google OR-Tools Protocol Buffers Binary File (*.bin)|*.bin"
+ }));
Problem = new LinearProgrammingProblem();
@@ -113,5 +118,5 @@
protected LinearProgrammingAlgorithm(LinearProgrammingAlgorithm original, Cloner cloner)
: base(original, cloner) {
- solverParam = cloner.Clone(original.solverParam);
+ linearSolverParam = cloner.Clone(original.linearSolverParam);
relativeGapToleranceParam = cloner.Clone(original.relativeGapToleranceParam);
timeLimitParam = cloner.Clone(original.timeLimitParam);
@@ -121,4 +126,5 @@
primalToleranceParam = cloner.Clone(original.primalToleranceParam);
scalingParam = cloner.Clone(original.scalingParam);
+ exportModelParam = cloner.Clone(original.exportModelParam);
}
@@ -128,4 +134,19 @@
}
+ public string ExportModel {
+ get => exportModelParam.Value.Value;
+ set => exportModelParam.Value.Value = value;
+ }
+
+ public ILinearSolver LinearSolver {
+ get => linearSolverParam.Value;
+ set => linearSolverParam.Value = value;
+ }
+
+ public IConstrainedValueParameter LinearSolverParameter {
+ get => linearSolverParam;
+ set => linearSolverParam = value;
+ }
+
public LpAlgorithmValues LpAlgorithm {
get => lpAlgorithmParam.Value.Value;
@@ -162,12 +183,7 @@
}
- public ISolver Solver {
- get => solverParam.Value;
- set => solverParam.Value = value;
- }
-
- public override bool SupportsPause => Solver.SupportsPause;
-
- public override bool SupportsStop => Solver.SupportsStop;
+ public override bool SupportsPause => LinearSolver.SupportsPause;
+
+ public override bool SupportsStop => LinearSolver.SupportsStop;
public TimeSpan TimeLimit {
@@ -180,5 +196,5 @@
public override void Pause() {
base.Pause();
- Solver.InterruptSolve();
+ LinearSolver.InterruptSolve();
}
@@ -187,5 +203,5 @@
Results.Clear();
- foreach (var solver in solverParam.ValidValues) {
+ foreach (var solver in linearSolverParam.ValidValues) {
solver.Reset();
}
@@ -194,8 +210,20 @@
public override void Stop() {
base.Stop();
- Solver.InterruptSolve();
- }
-
- protected override void Run(CancellationToken cancellationToken) => Solver.Solve(this, cancellationToken);
+ LinearSolver.InterruptSolve();
+ }
+
+ protected override void Run(CancellationToken cancellationToken) {
+ LinearSolver.PrimalTolerance = PrimalTolerance;
+ LinearSolver.DualTolerance = DualTolerance;
+ LinearSolver.LpAlgorithm = LpAlgorithm;
+ LinearSolver.Presolve = Presolve;
+ LinearSolver.RelativeGapTolerance = RelativeGapTolerance;
+ LinearSolver.Scaling = Scaling;
+ LinearSolver.TimeLimit = TimeLimit;
+ LinearSolver.ExportModel = ExportModel;
+ var executionTime = ExecutionTime;
+ ExecutionTimeChanged += (sender, args) => executionTime = ExecutionTime;
+ LinearSolver.Solve(Problem.ProblemDefinition, ref executionTime, Results, cancellationToken);
+ }
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LpAlgorithmValues.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LpAlgorithmValues.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/LpAlgorithmValues.cs (revision 16405)
@@ -0,0 +1,29 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public enum LpAlgorithmValues {
+ DualSimplex = 10,
+ PrimalSimplex = 11,
+ BarrierAlgorithm = 12
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProblemType.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProblemType.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProblemType.cs (revision 16405)
@@ -20,5 +20,5 @@
#endregion
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
public enum ProblemType {
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProtoWriteFormat.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProtoWriteFormat.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/ProtoWriteFormat.cs (revision 16405)
@@ -0,0 +1,29 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public enum ProtoWriteFormat {
+ ProtoText,
+ ProtoBinary,
+ Json
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/SolverResponseStatus.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/SolverResponseStatus.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/SolverResponseStatus.cs (revision 16405)
@@ -0,0 +1,38 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public enum SolverResponseStatus {
+ Optimal = 0,
+ Feasible = 1,
+ Infeasible = 2,
+ Unbounded = 3,
+ Abnormal = 4,
+ ModelInvalid = 5,
+ NotSolved = 6,
+ SolverTypeUnavailable = 7,
+ ModelInvalidSolutionHint = 84,
+ ModelInvalidSolverParameters = 85,
+ ModelIsValid = 97,
+ UnknownStatus = 99
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalLinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalLinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalLinearSolver.cs (revision 16405)
@@ -0,0 +1,58 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [StorableClass]
+ public class ExternalIncrementalLinearSolver : IncrementalLinearSolver, IExternalLinearSolver {
+ protected const string FileDialogFilter = "Dynamic-Link Library (*.dll)|*.dll|All Files (*.*)|*.*";
+
+ [Storable]
+ protected IFixedValueParameter libraryNameParam;
+
+ public ExternalIncrementalLinearSolver() {
+ }
+
+ [StorableConstructor]
+ protected ExternalIncrementalLinearSolver(bool deserializing)
+ : base(deserializing) {
+ }
+
+ protected ExternalIncrementalLinearSolver(ExternalIncrementalLinearSolver original, Cloner cloner)
+ : base(original, cloner) {
+ libraryNameParam = cloner.Clone(original.libraryNameParam);
+ }
+
+ public string LibraryName {
+ get => libraryNameParam?.Value.Value;
+ set => libraryNameParam.Value.Value = value;
+ }
+
+ protected override Solver CreateSolver(OptimizationProblemType optimizationProblemType,
+ string libraryName = null) => base.CreateSolver(optimizationProblemType, LibraryName);
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalIncrementalSolver.cs (revision 16404)
+++ (revision )
@@ -1,54 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- [StorableClass]
- public class ExternalIncrementalSolver : IncrementalSolver, IExternalSolver {
- protected const string FileDialogFilter = "Dynamic-Link Library (*.dll)|*.dll|All Files (*.*)|*.*";
-
- [Storable]
- protected IFixedValueParameter libraryNameParam;
-
- public ExternalIncrementalSolver() {
- }
-
- [StorableConstructor]
- protected ExternalIncrementalSolver(bool deserializing)
- : base(deserializing) {
- }
-
- protected ExternalIncrementalSolver(ExternalIncrementalSolver original, Cloner cloner)
- : base(original, cloner) {
- libraryNameParam = cloner.Clone(original.libraryNameParam);
- }
-
- public string LibraryName {
- get => libraryNameParam?.Value.Value;
- set => libraryNameParam.Value.Value = value;
- }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalLinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalLinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalLinearSolver.cs (revision 16405)
@@ -0,0 +1,58 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [StorableClass]
+ public class ExternalLinearSolver : LinearSolver, IExternalLinearSolver {
+ protected const string FileDialogFilter = "Dynamic-Link Library (*.dll)|*.dll|All Files (*.*)|*.*";
+
+ [Storable]
+ protected IFixedValueParameter libraryNameParam;
+
+ public ExternalLinearSolver() {
+ }
+
+ [StorableConstructor]
+ protected ExternalLinearSolver(bool deserializing)
+ : base(deserializing) {
+ }
+
+ protected ExternalLinearSolver(ExternalLinearSolver original, Cloner cloner)
+ : base(original, cloner) {
+ libraryNameParam = cloner.Clone(original.libraryNameParam);
+ }
+
+ public string LibraryName {
+ get => libraryNameParam?.Value.Value;
+ set => libraryNameParam.Value.Value = value;
+ }
+
+ protected override Solver CreateSolver(OptimizationProblemType optimizationProblemType,
+ string libraryName = null) => base.CreateSolver(optimizationProblemType, LibraryName);
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ExternalSolver.cs (revision 16404)
+++ (revision )
@@ -1,54 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- [StorableClass]
- public class ExternalSolver : Solver, IExternalSolver {
- protected const string FileDialogFilter = "Dynamic-Link Library (*.dll)|*.dll|All Files (*.*)|*.*";
-
- [Storable]
- protected IFixedValueParameter libraryNameParam;
-
- public ExternalSolver() {
- }
-
- [StorableConstructor]
- protected ExternalSolver(bool deserializing)
- : base(deserializing) {
- }
-
- protected ExternalSolver(ExternalSolver original, Cloner cloner)
- : base(original, cloner) {
- libraryNameParam = cloner.Clone(original.libraryNameParam);
- }
-
- public string LibraryName {
- get => libraryNameParam?.Value.Value;
- set => libraryNameParam.Value.Value = value;
- }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalLinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalLinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalLinearSolver.cs (revision 16405)
@@ -0,0 +1,27 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public interface IExternalLinearSolver : ILinearSolver {
+ string LibraryName { get; set; }
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IExternalSolver.cs (revision 16404)
+++ (revision )
@@ -1,27 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- public interface IExternalSolver : ISolver {
- string LibraryName { get; set; }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalLinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalLinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalLinearSolver.cs (revision 16405)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public interface IIncrementalLinearSolver : ILinearSolver {
+ TimeSpan QualityUpdateInterval { get; set; }
+ bool SupportsQualityUpdate { get; }
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IIncrementalSolver.cs (revision 16404)
+++ (revision )
@@ -1,30 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- public interface IIncrementalSolver : ISolver {
- TimeSpan QualityUpdateInterval { get; set; }
- bool SupportsQualityUpdate { get; }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ILinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ILinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ILinearSolver.cs (revision 16405)
@@ -0,0 +1,63 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Threading;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public interface ILinearSolver : IParameterizedNamedItem {
+ double DualTolerance { get; set; }
+
+ string ExportModel { get; set; }
+
+ bool Incrementality { get; set; }
+
+ LpAlgorithmValues LpAlgorithm { get; set; }
+
+ bool Presolve { get; set; }
+
+ double PrimalTolerance { get; set; }
+
+ ProblemType ProblemType { get; }
+
+ double RelativeGapTolerance { get; set; }
+
+ bool Scaling { get; set; }
+
+ bool SupportsPause { get; }
+
+ bool SupportsStop { get; }
+
+ TimeSpan TimeLimit { get; set; }
+
+ bool InterruptSolve();
+
+ void Reset();
+
+ void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime, ResultCollection results);
+
+ void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime,
+ ResultCollection results, CancellationToken cancellationToken);
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ISolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/ISolver.cs (revision 16404)
+++ (revision )
@@ -1,40 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System.Threading;
-using HeuristicLab.Core;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- public interface ISolver : IParameterizedNamedItem {
- ProblemType ProblemType { get; set; }
- bool SupportsPause { get; }
- bool SupportsStop { get; }
-
- bool InterruptSolve();
-
- void Reset();
-
- void Solve(LinearProgrammingAlgorithm algorithm);
-
- void Solve(LinearProgrammingAlgorithm algorithm, CancellationToken cancellationToken);
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalLinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalLinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalLinearSolver.cs (revision 16405)
@@ -0,0 +1,172 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Linq;
+using System.Threading;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [StorableClass]
+ public class IncrementalLinearSolver : LinearSolver, IIncrementalLinearSolver {
+ [Storable] protected readonly IValueParameter qualityUpdateIntervalParam;
+
+ private IndexedDataRow bpcRow;
+
+ private IndexedDataRow qpcRow;
+
+ [Storable] private IndexedDataTable qualityPerClock;
+
+ public IncrementalLinearSolver() {
+ Parameters.Add(qualityUpdateIntervalParam =
+ new ValueParameter(nameof(QualityUpdateInterval),
+ "Time interval before solver is paused, results are retrieved and solver is resumed. " +
+ "Set to zero for no intermediate results and faster solving.", new TimeSpanValue(new TimeSpan(0, 0, 10))));
+ problemTypeParam.Value.ValueChanged += (sender, args) => {
+ if (SupportsQualityUpdate) {
+ if (!Parameters.Contains(qualityUpdateIntervalParam)) {
+ Parameters.Add(qualityUpdateIntervalParam);
+ }
+ } else {
+ Parameters.Remove(qualityUpdateIntervalParam);
+ }
+ };
+ }
+
+ [StorableConstructor]
+ protected IncrementalLinearSolver(bool deserializing)
+ : base(deserializing) {
+ }
+
+ protected IncrementalLinearSolver(IncrementalLinearSolver original, Cloner cloner)
+ : base(original, cloner) {
+ problemTypeParam = cloner.Clone(original.problemTypeParam);
+ qualityUpdateIntervalParam = cloner.Clone(original.qualityUpdateIntervalParam);
+ if (original.qualityPerClock != null)
+ qualityPerClock = cloner.Clone(original.qualityPerClock);
+ }
+
+ public TimeSpan QualityUpdateInterval {
+ get => qualityUpdateIntervalParam.Value.Value;
+ set => qualityUpdateIntervalParam.Value.Value = value;
+ }
+
+ public virtual bool SupportsQualityUpdate => true;
+ protected virtual TimeSpan IntermediateTimeLimit => QualityUpdateInterval;
+
+ public override void Solve(ILinearProgrammingProblemDefinition problemDefinition, ref TimeSpan executionTime,
+ ResultCollection results, CancellationToken cancellationToken) {
+ if (!SupportsQualityUpdate || QualityUpdateInterval == TimeSpan.Zero) {
+ base.Solve(problemDefinition, ref executionTime, results, cancellationToken);
+ return;
+ }
+
+ var timeLimit = TimeLimit;
+ var unlimitedRuntime = timeLimit == TimeSpan.Zero;
+
+ if (!unlimitedRuntime) {
+ timeLimit -= executionTime;
+ }
+
+ var iterations = (long)timeLimit.TotalMilliseconds / (long)QualityUpdateInterval.TotalMilliseconds;
+ var remaining = timeLimit - TimeSpan.FromMilliseconds(iterations * QualityUpdateInterval.TotalMilliseconds);
+ var validResultStatuses = new[] { ResultStatus.NotSolved, ResultStatus.Feasible };
+
+ while (unlimitedRuntime || iterations > 0) {
+ if (cancellationToken.IsCancellationRequested)
+ return;
+
+ Solve(problemDefinition, results, IntermediateTimeLimit);
+ UpdateQuality(results, executionTime);
+
+ var resultStatus = ((EnumValue)results["ResultStatus"].Value).Value;
+ if (!validResultStatuses.Contains(resultStatus))
+ return;
+
+ if (!unlimitedRuntime)
+ iterations--;
+ }
+
+ if (remaining > TimeSpan.Zero) {
+ Solve(problemDefinition, results, remaining);
+ UpdateQuality(results, executionTime);
+ }
+ }
+
+ private void UpdateQuality(ResultCollection results, TimeSpan executionTime) {
+ if (!results.Exists(r => r.Name == "QualityPerClock")) {
+ qualityPerClock = new IndexedDataTable("Quality per Clock");
+ qpcRow = new IndexedDataRow("Objective Value");
+ bpcRow = new IndexedDataRow("Bound");
+ results.AddOrUpdateResult("QualityPerClock", qualityPerClock);
+ }
+
+ var resultStatus = ((EnumValue)results["ResultStatus"].Value).Value;
+
+ if (new[] { ResultStatus.Abnormal, ResultStatus.NotSolved, ResultStatus.Unbounded }.Contains(resultStatus))
+ return;
+
+ var objective = ((DoubleValue)results["BestObjectiveValue"].Value).Value;
+ var bound = solver.IsMIP() ? ((DoubleValue)results["BestObjectiveBound"].Value).Value : double.NaN;
+ var time = executionTime.TotalSeconds;
+
+ if (!qpcRow.Values.Any()) {
+ if (!double.IsInfinity(objective) && !double.IsNaN(objective)) {
+ qpcRow.Values.Add(Tuple.Create(time, objective));
+ qpcRow.Values.Add(Tuple.Create(time, objective));
+ qualityPerClock.Rows.Add(qpcRow);
+ results.AddOrUpdateResult("BestObjectiveValueFoundAt", new TimeSpanValue(TimeSpan.FromSeconds(time)));
+ }
+ } else {
+ var previousBest = qpcRow.Values.Last().Item2;
+ qpcRow.Values[qpcRow.Values.Count - 1] = Tuple.Create(time, objective);
+ if (!objective.IsAlmost(previousBest)) {
+ qpcRow.Values.Add(Tuple.Create(time, objective));
+ results.AddOrUpdateResult("BestObjectiveValueFoundAt", new TimeSpanValue(TimeSpan.FromSeconds(time)));
+ }
+ }
+
+ if (!solver.IsMIP())
+ return;
+
+ if (!bpcRow.Values.Any()) {
+ if (!double.IsInfinity(bound) && !double.IsNaN(bound)) {
+ bpcRow.Values.Add(Tuple.Create(time, bound));
+ bpcRow.Values.Add(Tuple.Create(time, bound));
+ qualityPerClock.Rows.Add(bpcRow);
+ }
+ } else {
+ var previousBest = bpcRow.Values.Last().Item2;
+ bpcRow.Values[bpcRow.Values.Count - 1] = Tuple.Create(time, bound);
+ if (!bound.IsAlmost(previousBest)) {
+ bpcRow.Values.Add(Tuple.Create(time, bound));
+ }
+ }
+ }
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/IncrementalSolver.cs (revision 16404)
+++ (revision )
@@ -1,174 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Linq;
-using System.Threading;
-using HeuristicLab.Analysis;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- [StorableClass]
- public class IncrementalSolver : Solver, IIncrementalSolver {
-
- [Storable]
- protected readonly IValueParameter qualityUpdateIntervalParam;
-
- private IndexedDataRow bpcRow;
-
- private IndexedDataRow qpcRow;
-
- [Storable]
- private IndexedDataTable qualityPerClock;
-
- [StorableConstructor]
- protected IncrementalSolver(bool deserializing)
- : base(deserializing) {
- }
-
- public IncrementalSolver() {
- Parameters.Add(qualityUpdateIntervalParam =
- new ValueParameter(nameof(QualityUpdateInterval),
- "Time interval before solver is paused, results are retrieved and solver is resumed. " +
- "Set to zero for no intermediate results and faster solving.", new TimeSpanValue(new TimeSpan(0, 0, 10))));
- problemTypeParam.Value.ValueChanged += (sender, args) => {
- if (SupportsQualityUpdate) {
- if (!Parameters.Contains(qualityUpdateIntervalParam)) {
- Parameters.Add(qualityUpdateIntervalParam);
- }
- } else {
- Parameters.Remove(qualityUpdateIntervalParam);
- }
- };
- }
-
- protected IncrementalSolver(IncrementalSolver original, Cloner cloner)
- : base(original, cloner) {
- problemTypeParam = cloner.Clone(original.problemTypeParam);
- qualityUpdateIntervalParam = cloner.Clone(original.qualityUpdateIntervalParam);
- if (original.qualityPerClock != null)
- qualityPerClock = cloner.Clone(original.qualityPerClock);
- }
-
- public virtual bool SupportsQualityUpdate => true;
-
- public TimeSpan QualityUpdateInterval {
- get => qualityUpdateIntervalParam.Value.Value;
- set => qualityUpdateIntervalParam.Value.Value = value;
- }
-
- protected virtual TimeSpan TimeLimit => QualityUpdateInterval;
-
- public override void Solve(LinearProgrammingAlgorithm algorithm, CancellationToken cancellationToken) {
- if (!SupportsQualityUpdate || QualityUpdateInterval == TimeSpan.Zero) {
- base.Solve(algorithm, cancellationToken);
- return;
- }
-
- var timeLimit = algorithm.TimeLimit;
- var unlimitedRuntime = timeLimit == TimeSpan.Zero;
-
- if (!unlimitedRuntime) {
- timeLimit -= algorithm.ExecutionTime;
- }
-
- var iterations = (long)timeLimit.TotalMilliseconds / (long)QualityUpdateInterval.TotalMilliseconds;
- var remaining = timeLimit - TimeSpan.FromMilliseconds(iterations * QualityUpdateInterval.TotalMilliseconds);
- var validResultStatuses = new[] { ResultStatus.NotSolved, ResultStatus.Feasible };
-
- while (unlimitedRuntime || iterations > 0) {
- if (cancellationToken.IsCancellationRequested)
- return;
-
- base.Solve(algorithm, TimeLimit);
- UpdateQuality(algorithm);
-
- var resultStatus = ((EnumValue)algorithm.Results[nameof(solver.ResultStatus)].Value).Value;
- if (!validResultStatuses.Contains(resultStatus))
- return;
-
- if (!unlimitedRuntime)
- iterations--;
- }
-
- if (remaining > TimeSpan.Zero) {
- base.Solve(algorithm, remaining);
- UpdateQuality(algorithm);
- }
- }
-
- private void UpdateQuality(LinearProgrammingAlgorithm algorithm) {
- if (!algorithm.Results.Exists(r => r.Name == "QualityPerClock")) {
- qualityPerClock = new IndexedDataTable("Quality per Clock");
- qpcRow = new IndexedDataRow("Objective Value");
- bpcRow = new IndexedDataRow("Bound");
- algorithm.Results.AddOrUpdateResult("QualityPerClock", qualityPerClock);
- }
-
- var resultStatus = ((EnumValue)algorithm.Results[nameof(solver.ResultStatus)].Value).Value;
-
- if (new[] { ResultStatus.Abnormal, ResultStatus.NotSolved, ResultStatus.Unbounded }.Contains(resultStatus))
- return;
-
- var objective = ((DoubleValue)algorithm.Results[$"Best{nameof(solver.ObjectiveValue)}"].Value).Value;
- var bound = solver.IsMip ? ((DoubleValue)algorithm.Results[$"Best{nameof(solver.ObjectiveBound)}"].Value).Value : double.NaN;
- var time = algorithm.ExecutionTime.TotalSeconds;
-
- if (!qpcRow.Values.Any()) {
- if (!double.IsInfinity(objective) && !double.IsNaN(objective)) {
- qpcRow.Values.Add(Tuple.Create(time, objective));
- qpcRow.Values.Add(Tuple.Create(time, objective));
- qualityPerClock.Rows.Add(qpcRow);
- algorithm.Results.AddOrUpdateResult($"Best{nameof(solver.ObjectiveValue)}FoundAt", new TimeSpanValue(TimeSpan.FromSeconds(time)));
- }
- } else {
- var previousBest = qpcRow.Values.Last().Item2;
- qpcRow.Values[qpcRow.Values.Count - 1] = Tuple.Create(time, objective);
- if (!objective.IsAlmost(previousBest)) {
- qpcRow.Values.Add(Tuple.Create(time, objective));
- algorithm.Results.AddOrUpdateResult($"Best{nameof(solver.ObjectiveValue)}FoundAt", new TimeSpanValue(TimeSpan.FromSeconds(time)));
- }
- }
-
- if (!solver.IsMip)
- return;
-
- if (!bpcRow.Values.Any()) {
- if (!double.IsInfinity(bound) && !double.IsNaN(bound)) {
- bpcRow.Values.Add(Tuple.Create(time, bound));
- bpcRow.Values.Add(Tuple.Create(time, bound));
- qualityPerClock.Rows.Add(bpcRow);
- }
- } else {
- var previousBest = bpcRow.Values.Last().Item2;
- bpcRow.Values[bpcRow.Values.Count - 1] = Tuple.Create(time, bound);
- if (!bound.IsAlmost(previousBest)) {
- bpcRow.Values.Add(Tuple.Create(time, bound));
- }
- }
- }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/LinearSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/LinearSolver.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/LinearSolver.cs (revision 16405)
@@ -0,0 +1,270 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Threading;
+using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [StorableClass]
+ public class LinearSolver : ParameterizedNamedItem, ILinearSolver, IDisposable {
+
+ [Storable]
+ protected IValueParameter> problemTypeParam;
+
+ protected Solver solver;
+
+ [Storable]
+ protected IFixedValueParameter solverSpecificParametersParam;
+
+ public LinearSolver() {
+ Parameters.Add(problemTypeParam =
+ new ValueParameter>(nameof(ProblemType), new EnumValue()));
+ Parameters.Add(solverSpecificParametersParam =
+ new FixedValueParameter(nameof(SolverSpecificParameters), new TextValue()));
+ }
+
+ [StorableConstructor]
+ protected LinearSolver(bool deserializing)
+ : base(deserializing) {
+ }
+
+ protected LinearSolver(LinearSolver original, Cloner cloner)
+ : base(original, cloner) {
+ problemTypeParam = cloner.Clone(original.problemTypeParam);
+ solverSpecificParametersParam = cloner.Clone(original.solverSpecificParametersParam);
+ }
+
+ public double DualTolerance { get; set; } = MPSolverParameters.kDefaultDualTolerance;
+
+ public string ExportModel { get; set; }
+
+ public bool Incrementality { get; set; } =
+ MPSolverParameters.kDefaultIncrementality == MPSolverParameters.INCREMENTALITY_ON;
+
+ public LpAlgorithmValues LpAlgorithm { get; set; }
+
+ public bool Presolve { get; set; } = MPSolverParameters.kDefaultPresolve == MPSolverParameters.PRESOLVE_ON;
+
+ public double PrimalTolerance { get; set; } = MPSolverParameters.kDefaultPrimalTolerance;
+
+ public ProblemType ProblemType {
+ get => problemTypeParam.Value.Value;
+ set => problemTypeParam.Value.Value = value;
+ }
+
+ public double RelativeGapTolerance { get; set; } = MPSolverParameters.kDefaultRelativeMipGap;
+
+ public bool Scaling { get; set; }
+
+ public string SolverSpecificParameters {
+ get => solverSpecificParametersParam.Value.Value;
+ set => solverSpecificParametersParam.Value.Value = value;
+ }
+
+ public virtual bool SupportsPause => true;
+ public virtual bool SupportsStop => true;
+ public virtual TimeSpan TimeLimit { get; set; } = TimeSpan.Zero;
+ protected virtual OptimizationProblemType OptimizationProblemType { get; }
+
+ public override IDeepCloneable Clone(Cloner cloner) => new LinearSolver(this, cloner);
+
+ public void Dispose() => solver?.Dispose();
+
+ public bool ExportAsLp(string fileName, bool obfuscated = false) {
+ var lpFormat = solver?.ExportModelAsLpFormat(obfuscated);
+ if (string.IsNullOrEmpty(lpFormat))
+ return false;
+ File.WriteAllText(fileName, lpFormat);
+ return true;
+ }
+
+ public bool ExportAsMps(string fileName, bool fixedFormat = false, bool obfuscated = false) {
+ var mpsFormat = solver?.ExportModelAsMpsFormat(fixedFormat, obfuscated);
+ if (string.IsNullOrEmpty(mpsFormat))
+ return false;
+ File.WriteAllText(fileName, mpsFormat);
+ return true;
+ }
+
+ public bool ExportAsProto(string fileName, ProtoWriteFormat writeFormat = ProtoWriteFormat.ProtoBinary) =>
+ solver != null && solver.ExportModelAsProtoFormat(fileName, (int)writeFormat);
+
+ public SolverResponseStatus ImportFromMps(string fileName, bool? fixedFormat) => solver == null
+ ? SolverResponseStatus.Abnormal
+ : (SolverResponseStatus)solver.ImportModelFromMpsFormat(fileName, fixedFormat.HasValue, fixedFormat ?? false);
+
+ public SolverResponseStatus ImportFromProto(string fileName) => solver == null
+ ? SolverResponseStatus.Abnormal
+ : (SolverResponseStatus)solver.ImportModelFromProtoFormat(fileName);
+
+ public bool InterruptSolve() => solver?.InterruptSolve() ?? false;
+
+ public virtual void Reset() {
+ solver?.Dispose();
+ solver = null;
+ }
+
+ public virtual void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime,
+ ResultCollection results, CancellationToken cancellationToken) =>
+ Solve(problemDefintion, ref executionTime, results);
+
+ public virtual void Solve(ILinearProgrammingProblemDefinition problemDefinition, ref TimeSpan executionTime,
+ ResultCollection results) =>
+ Solve(problemDefinition, results, TimeLimit);
+
+ public virtual void Solve(ILinearProgrammingProblemDefinition problemDefinition, ResultCollection results,
+ TimeSpan timeLimit) {
+ if (solver == null) {
+ solver = CreateSolver(OptimizationProblemType);
+ problemDefinition.BuildModel(solver);
+ }
+
+ if (timeLimit > TimeSpan.Zero) {
+ solver.SetTimeLimit((long)timeLimit.TotalMilliseconds);
+ } else {
+ solver.SetTimeLimit(0);
+ }
+
+ ResultStatus resultStatus;
+
+ using (var parameters = new MPSolverParameters()) {
+ parameters.SetDoubleParam(MPSolverParameters.RELATIVE_MIP_GAP, RelativeGapTolerance);
+ parameters.SetDoubleParam(MPSolverParameters.PRIMAL_TOLERANCE, PrimalTolerance);
+ parameters.SetDoubleParam(MPSolverParameters.DUAL_TOLERANCE, DualTolerance);
+ parameters.SetIntegerParam(MPSolverParameters.PRESOLVE,
+ Presolve ? MPSolverParameters.PRESOLVE_ON : MPSolverParameters.PRESOLVE_OFF);
+ parameters.SetIntegerParam(MPSolverParameters.LP_ALGORITHM, (int)LpAlgorithm);
+ parameters.SetIntegerParam(MPSolverParameters.INCREMENTALITY,
+ Incrementality ? MPSolverParameters.INCREMENTALITY_ON : MPSolverParameters.INCREMENTALITY_OFF);
+ parameters.SetIntegerParam(MPSolverParameters.SCALING,
+ Scaling ? MPSolverParameters.SCALING_ON : MPSolverParameters.SCALING_OFF);
+
+ if (!solver.SetSolverSpecificParametersAsString(SolverSpecificParameters))
+ throw new ArgumentException("Solver specific parameters could not be set.");
+
+ if (!string.IsNullOrWhiteSpace(ExportModel)) {
+ var fileInfo = new FileInfo(ExportModel);
+
+ if (!fileInfo.Directory?.Exists ?? false) {
+ Directory.CreateDirectory(fileInfo.Directory.FullName);
+ }
+
+ bool exportSuccessful;
+ switch (fileInfo.Extension) {
+ case ".lp":
+ exportSuccessful = ExportAsLp(ExportModel);
+ break;
+
+ case ".mps":
+ exportSuccessful = ExportAsMps(ExportModel);
+ break;
+
+ case ".prototxt":
+ exportSuccessful = ExportAsProto(ExportModel, ProtoWriteFormat.ProtoText);
+ break;
+
+ case ".bin": // remove file extension as it is added by OR-Tools
+ exportSuccessful = ExportAsProto(Path.ChangeExtension(ExportModel, null));
+ break;
+
+ default:
+ throw new NotSupportedException("File format selected to export model is not supported.");
+ }
+ }
+
+ // TODO: show warning if file export didn't work (if exportSuccessful is false)
+
+ resultStatus = (ResultStatus)solver.Solve(parameters);
+ }
+
+ var objectiveValue = solver.Objective()?.Value();
+
+ problemDefinition.Analyze(solver, results);
+ results.AddOrUpdateResult("ResultStatus", new EnumValue(resultStatus));
+ results.AddOrUpdateResult("BestObjectiveValue", new DoubleValue(objectiveValue ?? double.NaN));
+
+ if (solver.IsMIP()) {
+ var objectiveBound = solver.Objective()?.BestBound();
+ var absoluteGap = objectiveValue.HasValue && objectiveBound.HasValue
+ ? Math.Abs(objectiveBound.Value - objectiveValue.Value)
+ : (double?)null;
+ // https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/Parameters/topics/EpGap.html
+ var relativeGap = absoluteGap.HasValue && objectiveValue.HasValue
+ ? absoluteGap.Value / (1e-10 + Math.Abs(objectiveValue.Value))
+ : (double?)null;
+
+ results.AddOrUpdateResult("BestObjectiveBound", new DoubleValue(objectiveBound ?? double.NaN));
+ results.AddOrUpdateResult("AbsoluteGap", new DoubleValue(absoluteGap ?? double.NaN));
+ results.AddOrUpdateResult("RelativeGap", new PercentValue(relativeGap ?? double.NaN));
+ }
+
+ results.AddOrUpdateResult("NumberOfConstraints", new IntValue(solver.NumConstraints()));
+ results.AddOrUpdateResult("NumberOfVariables", new IntValue(solver.NumVariables()));
+
+ if (solver.IsMIP() && solver.Nodes() >= 0) {
+ results.AddOrUpdateResult(nameof(solver.Nodes), new DoubleValue(solver.Nodes()));
+ }
+
+ if (solver.Iterations() >= 0) {
+ results.AddOrUpdateResult(nameof(solver.Iterations), new DoubleValue(solver.Iterations()));
+ }
+
+ results.AddOrUpdateResult(nameof(solver.SolverVersion), new StringValue(solver.SolverVersion()));
+ }
+
+ protected virtual Solver CreateSolver(OptimizationProblemType optimizationProblemType, string libraryName = null) {
+ if (!string.IsNullOrEmpty(libraryName) && !File.Exists(libraryName)) {
+ var paths = new List {
+ Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)
+ };
+ var path = Environment.GetEnvironmentVariable("PATH");
+ if (path != null)
+ paths.AddRange(path.Split(';'));
+ if (!paths.Any(p => File.Exists(Path.Combine(p, libraryName))))
+ throw new FileNotFoundException($"Could not find library {libraryName} in PATH.", libraryName);
+ }
+
+ try {
+ solver = new Solver(Name, (int)optimizationProblemType, libraryName ?? string.Empty);
+ } catch {
+ throw new InvalidOperationException($"Could not create {optimizationProblemType}.");
+ }
+
+ if (solver == null)
+ throw new InvalidOperationException($"Could not create {optimizationProblemType}.");
+
+ solver.SuppressOutput();
+ return solver;
+ }
+ }
+}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/Solver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/Base/Solver.cs (revision 16404)
+++ (revision )
@@ -1,139 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Threading;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Parameters;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base {
-
- [StorableClass]
- public class Solver : ParameterizedNamedItem, ISolver, IDisposable {
-
- [Storable]
- protected IValueParameter> problemTypeParam;
-
- protected LinearSolver solver;
-
- [Storable]
- protected IFixedValueParameter solverSpecificParametersParam;
-
- public Solver() {
- Parameters.Add(problemTypeParam =
- new ValueParameter>(nameof(ProblemType), new EnumValue()));
- Parameters.Add(solverSpecificParametersParam =
- new FixedValueParameter(nameof(SolverSpecificParameters), new TextValue()));
- }
-
- [StorableConstructor]
- protected Solver(bool deserializing)
- : base(deserializing) {
- }
-
- protected Solver(Solver original, Cloner cloner)
- : base(original, cloner) {
- problemTypeParam = cloner.Clone(original.problemTypeParam);
- solverSpecificParametersParam = cloner.Clone(original.solverSpecificParametersParam);
- }
-
- public ProblemType ProblemType {
- get => problemTypeParam.Value.Value;
- set => problemTypeParam.Value.Value = value;
- }
-
- public TextValue SolverSpecificParameters => solverSpecificParametersParam.Value;
-
- public virtual bool SupportsPause => true;
- public virtual bool SupportsStop => true;
- protected virtual OptimizationProblemType OptimizationProblemType { get; }
-
- public override IDeepCloneable Clone(Cloner cloner) => new Solver(this, cloner);
-
- public void Dispose() => solver?.Dispose();
-
- public bool InterruptSolve() => solver?.InterruptSolve() ?? false;
-
- public virtual void Reset() {
- solver?.Dispose();
- solver = null;
- }
-
- public virtual void Solve(LinearProgrammingAlgorithm algorithm, CancellationToken cancellationToken) =>
- Solve(algorithm);
-
- public virtual void Solve(LinearProgrammingAlgorithm algorithm) =>
- Solve(algorithm, algorithm.TimeLimit);
-
- public virtual void Solve(LinearProgrammingAlgorithm algorithm, TimeSpan timeLimit) {
- string libraryName = null;
- if (this is IExternalSolver externalSolver)
- libraryName = externalSolver.LibraryName;
-
- if (solver == null) {
- solver = new LinearSolver(OptimizationProblemType, s => algorithm.Problem.ProblemDefinition.BuildModel(s), Name,
- libraryName);
- }
-
- solver.TimeLimit = timeLimit;
- solver.RelativeGapTolerance = algorithm.RelativeGapTolerance;
- solver.PrimalTolerance = algorithm.PrimalTolerance;
- solver.DualTolerance = algorithm.DualTolerance;
- solver.Presolve = algorithm.Presolve;
- solver.Scaling = algorithm.Scaling;
- solver.LpAlgorithm = algorithm.LpAlgorithm;
- solver.Incrementality = true;
-
- if (!solver.SetSolverSpecificParameters(SolverSpecificParameters.Value))
- throw new ArgumentException("Solver specific parameters could not be set.");
-
- solver.Solve();
-
- algorithm.Problem.ProblemDefinition.Analyze(solver.Solver, algorithm.Results);
- algorithm.Results.AddOrUpdateResult(nameof(solver.ResultStatus),
- new EnumValue(solver.ResultStatus));
- algorithm.Results.AddOrUpdateResult($"Best{nameof(solver.ObjectiveValue)}",
- new DoubleValue(solver.ObjectiveValue ?? double.NaN));
-
- if (solver.IsMip) {
- algorithm.Results.AddOrUpdateResult($"Best{nameof(solver.ObjectiveBound)}",
- new DoubleValue(solver.ObjectiveBound ?? double.NaN));
- algorithm.Results.AddOrUpdateResult(nameof(solver.AbsoluteGap),
- new DoubleValue(solver.AbsoluteGap ?? double.NaN));
- algorithm.Results.AddOrUpdateResult(nameof(solver.RelativeGap),
- new PercentValue(solver.RelativeGap ?? double.NaN));
- }
-
- algorithm.Results.AddOrUpdateResult(nameof(solver.NumberOfConstraints), new IntValue(solver.NumberOfConstraints));
- algorithm.Results.AddOrUpdateResult(nameof(solver.NumberOfVariables), new IntValue(solver.NumberOfVariables));
-
- if (solver.IsMip) {
- algorithm.Results.AddOrUpdateResult(nameof(solver.NumberOfNodes), new DoubleValue(solver.NumberOfNodes));
- }
-
- algorithm.Results.AddOrUpdateResult(nameof(solver.Iterations), new DoubleValue(solver.Iterations));
- algorithm.Results.AddOrUpdateResult(nameof(solver.SolverVersion), new StringValue(solver.SolverVersion));
- }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/BopSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/BopSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/BopSolver.cs (revision 16405)
@@ -24,18 +24,17 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("BOP", "BOP (https://developers.google.com/optimization/reference/bop/bop_solver/) can be used out of the box.")]
[StorableClass]
- public class BopSolver : IncrementalSolver {
+ public class BopSolver : IncrementalLinearSolver {
public BopSolver() {
Parameters.Remove(problemTypeParam);
Parameters.Add(new FixedValueParameter(nameof(ProblemType), new StringValue("ZeroOneProgramming").AsReadOnly()));
- SolverSpecificParameters.Value =
+ SolverSpecificParameters =
"# for file format, see Protocol Buffers text format (https://developers.google.com/protocol-buffers/docs/overview#whynotxml)" + Environment.NewLine +
"# for parameters, see https://github.com/google/or-tools/blob/v6.10/ortools/bop/bop_parameters.proto" + Environment.NewLine +
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CoinOrSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CoinOrSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CoinOrSolver.cs (revision 16405)
@@ -20,14 +20,15 @@
#endregion
+using System;
using HeuristicLab.Common;
using HeuristicLab.Core;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
+using HeuristicLab.Optimization;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[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.")]
[StorableClass]
- public class CoinOrSolver : IncrementalSolver {
+ public class CoinOrSolver : IncrementalLinearSolver {
public CoinOrSolver() {
@@ -54,4 +55,9 @@
? OptimizationProblemType.ClpLinearProgramming
: OptimizationProblemType.CbcMixedIntegerProgramming;
+
+ public override void Solve(ILinearProgrammingProblemDefinition problemDefinition, ResultCollection results, TimeSpan timeLimit) {
+ // TODO: warning that solver cannot be stopped or paused
+ base.Solve(problemDefinition, results, timeLimit);
+ }
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CplexSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CplexSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/CplexSolver.cs (revision 16405)
@@ -24,18 +24,17 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("CPLEX", "CPLEX (https://www.ibm.com/analytics/cplex-optimizer) must be installed and licenced.")]
[StorableClass]
- public class CplexSolver : ExternalIncrementalSolver {
+ public class CplexSolver : ExternalIncrementalLinearSolver {
public CplexSolver() {
Parameters.Add(libraryNameParam = new FixedValueParameter(nameof(LibraryName),
new FileValue { FileDialogFilter = FileDialogFilter, Value = Properties.Settings.Default.CplexLibraryName }));
- SolverSpecificParameters.Value =
+ SolverSpecificParameters =
"CPLEX Parameter File Version 12.8.0" + Environment.NewLine +
"# 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 +
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlopSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlopSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlopSolver.cs (revision 16405)
@@ -24,16 +24,15 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("Glop", "Glop (https://developers.google.com/optimization/lp/glop) can be used out of the box.")]
[StorableClass]
- public class GlopSolver : IncrementalSolver {
+ public class GlopSolver : IncrementalLinearSolver {
public GlopSolver() {
problemTypeParam.Value = (EnumValue)problemTypeParam.Value.AsReadOnly();
- SolverSpecificParameters.Value =
+ SolverSpecificParameters =
"# for file format, see Protocol Buffers text format (https://developers.google.com/protocol-buffers/docs/overview#whynotxml)" + Environment.NewLine +
"# for parameters, see https://github.com/google/or-tools/blob/v6.10/ortools/glop/parameters.proto" + Environment.NewLine +
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlpkSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlpkSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GlpkSolver.cs (revision 16405)
@@ -23,13 +23,12 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("GLPK", "GLPK (https://www.gnu.org/software/glpk/) can be used out of the box.")]
[StorableClass]
- public class GlpkSolver : ExternalIncrementalSolver {
+ public class GlpkSolver : ExternalLinearSolver {
public GlpkSolver() {
@@ -48,7 +47,5 @@
}
- public override bool SupportsPause => ProblemType == ProblemType.LinearProgramming; // TODO: pause working for linear programs?
-
- public override bool SupportsQualityUpdate => ProblemType == ProblemType.LinearProgramming;
+ public override bool SupportsPause => false;
protected override OptimizationProblemType OptimizationProblemType =>
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GurobiSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GurobiSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/GurobiSolver.cs (revision 16405)
@@ -24,18 +24,17 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("Gurobi", "Gurobi (http://www.gurobi.com/) must be installed and licenced.")]
[StorableClass]
- public class GurobiSolver : ExternalIncrementalSolver {
+ public class GurobiSolver : ExternalIncrementalLinearSolver {
public GurobiSolver() {
Parameters.Add(libraryNameParam = new FixedValueParameter(nameof(LibraryName),
new FileValue { FileDialogFilter = FileDialogFilter, Value = Properties.Settings.Default.GurobiLibraryName }));
- SolverSpecificParameters.Value =
+ SolverSpecificParameters =
"# for file format, see http://www.gurobi.com/documentation/8.1/refman/prm_format.html" + Environment.NewLine +
"# for parameters, see http://www.gurobi.com/documentation/8.1/refman/parameters.html" + Environment.NewLine +
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/ScipSolver.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/ScipSolver.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Algorithms/Solvers/ScipSolver.cs (revision 16405)
@@ -25,14 +25,13 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers.Base;
+using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Algorithms.Solvers {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("SCIP", "SCIP (http://scip.zib.de/) must be installed and licenced.")]
[StorableClass]
- public class ScipSolver : ExternalIncrementalSolver {
-
+ public class ScipSolver : ExternalIncrementalLinearSolver {
private TimeSpan timeLimit = TimeSpan.Zero;
@@ -42,5 +41,5 @@
problemTypeParam.Value =
(EnumValue)new EnumValue(ProblemType.MixedIntegerProgramming).AsReadOnly();
- SolverSpecificParameters.Value =
+ SolverSpecificParameters =
"# for file format and parameters, see https://scip.zib.de/doc/html/PARAMETERS.php" + Environment.NewLine +
"# example:" + Environment.NewLine +
@@ -57,11 +56,12 @@
}
+ protected override TimeSpan IntermediateTimeLimit => timeLimit += QualityUpdateInterval;
+
protected override OptimizationProblemType OptimizationProblemType =>
- OptimizationProblemType.ScipMixedIntegerProgramming;
- protected override TimeSpan TimeLimit => timeLimit += QualityUpdateInterval;
+ OptimizationProblemType.ScipMixedIntegerProgramming;
- public override void Solve(LinearProgrammingAlgorithm algorithm, CancellationToken cancellationToken) {
+ public override void Solve(ILinearProgrammingProblemDefinition problemDefintion, ref TimeSpan executionTime, ResultCollection results, CancellationToken cancellationToken) {
timeLimit = TimeSpan.Zero;
- base.Solve(algorithm, cancellationToken);
+ base.Solve(problemDefintion, ref executionTime, results, cancellationToken);
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/CompiledProblemDefinition.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/CompiledProblemDefinition.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/CompiledProblemDefinition.cs (revision 16405)
@@ -0,0 +1,29 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ public abstract class CompiledProblemDefinition {
+ public dynamic vars { get; set; }
+
+ public abstract void Initialize();
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/FileBasedLinearProgrammingProblemDefinition.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/FileBasedLinearProgrammingProblemDefinition.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/FileBasedLinearProgrammingProblemDefinition.cs (revision 16405)
@@ -0,0 +1,96 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System.Drawing;
+using System.IO;
+using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
+using HeuristicLab.Common.Resources;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [Item("File-Based Linear/Mixed Integer Programming Problem Definition", "File that defines the model for linear/mixed integer programming problem.")]
+ [StorableClass]
+ public sealed class FileBasedLinearProgrammingProblemDefinition : ParameterizedNamedItem, ILinearProgrammingProblemDefinition {
+
+ [Storable]
+ private readonly IFixedValueParameter fileNameParam;
+
+ [Storable]
+ private byte[] fileContent;
+
+ public FileBasedLinearProgrammingProblemDefinition() {
+ Parameters.Add(fileNameParam = new FixedValueParameter(nameof(FileName), new FileValue()));
+ fileNameParam.Value.FileDialogFilter =
+ "All Supported Files (*.mps;*.bin;*.prototxt)|*.mps;*.bin;*.prototxt|" +
+ "Mathematical Programming System Files (*.mps)|*.mps|" +
+ "Google OR-Tools Protocol Buffers Files (*.bin;*.prototxt)|*.bin;*.prototxt|" +
+ "All Files (*.*)|*.*";
+ fileNameParam.Value.PathChanged += (o, e) => {
+ if (File.Exists(FileName)) {
+ fileContent = File.ReadAllBytes(FileName);
+ }
+ };
+ }
+
+ private FileBasedLinearProgrammingProblemDefinition(FileBasedLinearProgrammingProblemDefinition original, Cloner cloner)
+ : base(original, cloner) {
+ fileNameParam = cloner.Clone(original.fileNameParam);
+ }
+
+ [StorableConstructor]
+ private FileBasedLinearProgrammingProblemDefinition(bool deserializing) : base(deserializing) { }
+
+ public new static Image StaticItemImage => VSImageLibrary.File;
+
+ public string FileName {
+ get => fileNameParam.Value.Value;
+ set => fileNameParam.Value.Value = value;
+ }
+
+ public IFixedValueParameter FileNameParam => fileNameParam;
+
+ public void Analyze(Solver solver, ResultCollection results) {
+ }
+
+ public void BuildModel(Solver solver) {
+ var fileInfo = new FileInfo(FileName);
+ var tempFileName = Path.GetTempFileName();
+ File.WriteAllBytes(tempFileName, fileContent);
+
+ var status = (SolverResponseStatus)(fileInfo.Extension == ".mps"
+ ? solver.ImportModelFromMpsFormat(tempFileName)
+ : solver.ImportModelFromProtoFormat(tempFileName));
+
+ if (status == SolverResponseStatus.Abnormal)
+ throw new FileFormatException($"'{FileName}' is not a valid MPS or Google OR-Tools Protocol Buffers file.");
+
+ File.Delete(tempFileName);
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) => new FileBasedLinearProgrammingProblemDefinition(this, cloner);
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ILinearProgrammingProblemDefinition.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ILinearProgrammingProblemDefinition.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ILinearProgrammingProblemDefinition.cs (revision 16405)
@@ -21,13 +21,14 @@
using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
using HeuristicLab.Optimization;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
- public interface ILinearProgrammingProblemDefinition {
-
- bool BuildModel(Solver solver);
+ public interface ILinearProgrammingProblemDefinition : IContent {
void Analyze(Solver solver, ResultCollection results);
+
+ void BuildModel(Solver solver);
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblem.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblem.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblem.cs (revision 16405)
@@ -20,52 +20,46 @@
#endregion
-using System.Drawing;
+using System;
using HeuristicLab.Common;
-using HeuristicLab.Common.Resources;
using HeuristicLab.Core;
using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
[Item("Linear/Mixed Integer Programming Problem (LP/MIP)", "Represents a linear/mixed integer problem.")]
- [Creatable(CreatableAttribute.Categories.CombinatorialProblems)]
[StorableClass]
- public class LinearProgrammingProblem : Problem, IProgrammableItem {
+ public sealed class LinearProgrammingProblem : Problem {
+ [Storable]
+ private ILinearProgrammingProblemDefinition problemDefinition;
public LinearProgrammingProblem() {
- Parameters.Add(new FixedValueParameter("ProblemScript",
- "Defines the problem.", new LinearProgrammingProblemDefinitionScript { Name = Name }) { GetsCollected = false });
- RegisterEvents();
+ Parameters.Remove(Parameters["Operators"]);
}
- protected LinearProgrammingProblem(LinearProgrammingProblem original, Cloner cloner)
+ private LinearProgrammingProblem(LinearProgrammingProblem original, Cloner cloner)
: base(original, cloner) {
- RegisterEvents();
}
[StorableConstructor]
- protected LinearProgrammingProblem(bool deserializing) : base(deserializing) { }
-
- public new static Image StaticItemImage => VSImageLibrary.Script;
- public ILinearProgrammingProblemDefinition ProblemDefinition => LinearProgrammingProblemScriptParameter.Value;
- public LinearProgrammingProblemDefinitionScript ProblemScript => LinearProgrammingProblemScriptParameter.Value;
-
- private FixedValueParameter LinearProgrammingProblemScriptParameter =>
- (FixedValueParameter)Parameters["ProblemScript"];
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new LinearProgrammingProblem(this, cloner);
+ private LinearProgrammingProblem(bool deserializing) : base(deserializing) {
}
- protected override void OnNameChanged() {
- base.OnNameChanged();
- ProblemScript.Name = Name;
+ public event EventHandler ProblemDefinitionChanged;
+
+ public ILinearProgrammingProblemDefinition ProblemDefinition {
+ get => problemDefinition;
+ set {
+ if (problemDefinition == value)
+ return;
+ problemDefinition = value;
+ ProblemDefinitionChanged?.Invoke(this, EventArgs.Empty);
+ }
}
+
+ public override IDeepCloneable Clone(Cloner cloner) => new LinearProgrammingProblem(this, cloner);
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
- RegisterEvents();
}
@@ -74,13 +68,4 @@
OnReset();
}
-
- private void OnProblemScriptNameChanged() {
- Name = ProblemScript.Name;
- }
-
- private void RegisterEvents() {
- ProblemScript.ProblemDefinitionChanged += (o, e) => OnProblemDefinitionChanged();
- ProblemScript.NameChanged += (o, e) => OnProblemScriptNameChanged();
- }
}
}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblemDefinitionScript.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblemDefinitionScript.cs (revision 16404)
+++ (revision )
@@ -1,150 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Linq;
-using System.Reflection;
-using Google.OrTools.LinearSolver;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Optimization;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-using HeuristicLab.Problems.Programmable;
-using HeuristicLab.Scripting;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
-
- [Item("Linear/Mixed Integer Programming Problem Definition Script", "Script that defines the model and evaluates the solution for a linear/mixed integer programming problem.")]
- [StorableClass]
- public sealed class LinearProgrammingProblemDefinitionScript : Script, ILinearProgrammingProblemDefinition, IStorableContent {
- private bool SuppressEvents { get; set; }
-
- [Storable]
- private readonly VariableStore variableStore;
-
- public VariableStore VariableStore => variableStore;
-
- [Storable]
- private bool codeChanged;
-
- [StorableConstructor]
- private LinearProgrammingProblemDefinitionScript(bool deserializing) : base(deserializing) { }
-
- private LinearProgrammingProblemDefinitionScript(LinearProgrammingProblemDefinitionScript original, Cloner cloner)
- : base(original, cloner) {
- variableStore = cloner.Clone(original.variableStore);
- codeChanged = original.codeChanged;
- }
-
- public LinearProgrammingProblemDefinitionScript()
- : base(ScriptTemplates.CompiledLinearProgrammingProblemDefinition) {
- variableStore = new VariableStore();
- }
-
- private readonly object compileLock = new object();
- private volatile ILinearProgrammingProblemDefinition compiledProblemDefinition;
-
- private ILinearProgrammingProblemDefinition CompiledProblemDefinition {
- get {
- // double checked locking pattern
- if (compiledProblemDefinition == null) {
- lock (compileLock) {
- if (compiledProblemDefinition == null) {
- if (codeChanged)
- throw new ProblemDefinitionScriptException("The code has been changed, but was not recompiled.");
- Compile(false);
- }
- }
- }
- return compiledProblemDefinition;
- }
- }
-
- public dynamic Instance => compiledProblemDefinition;
-
- public override Assembly Compile() => Compile(true);
-
- private Assembly Compile(bool fireChanged) {
- var assembly = base.Compile();
- var types = assembly.GetTypes();
- if (!types.Any(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)))
- throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." +
- Environment.NewLine +
- "The problem definition must be a subclass of CompiledProblemDefinition.");
- if (types.Count(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)) > 1)
- throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." +
- Environment.NewLine +
- "Only one subclass of CompiledProblemDefinition is allowed.");
-
- CompiledProblemDefinition inst;
- try {
- inst = (CompiledProblemDefinition)Activator.CreateInstance(types.Single(x =>
- typeof(CompiledProblemDefinition).IsAssignableFrom(x)));
- } catch (Exception e) {
- compiledProblemDefinition = null;
- throw new ProblemDefinitionScriptException(
- "Instantiating the problem definition failed." + Environment.NewLine + "Check your default constructor.", e);
- }
-
- try {
- inst.vars = new Variables(VariableStore);
- inst.Initialize();
- } catch (Exception e) {
- compiledProblemDefinition = null;
- throw new ProblemDefinitionScriptException(
- "Initializing the problem definition failed." + Environment.NewLine + "Check your Initialize() method.", e);
- }
-
- try {
- compiledProblemDefinition = (ILinearProgrammingProblemDefinition)inst;
- if (fireChanged) OnProblemDefinitionChanged();
- } catch (Exception e) {
- compiledProblemDefinition = null;
- throw new ProblemDefinitionScriptException(
- "Using the problem definition in the problem failed." + Environment.NewLine +
- "Examine this error message carefully (often there is an issue with the defined encoding).", e);
- }
-
- codeChanged = false;
- return assembly;
- }
-
- protected override void OnCodeChanged() {
- base.OnCodeChanged();
- compiledProblemDefinition = null;
- codeChanged = true;
- }
-
- public event EventHandler ProblemDefinitionChanged;
-
- private void OnProblemDefinitionChanged() => ProblemDefinitionChanged?.Invoke(this, EventArgs.Empty);
-
- public string Filename { get; set; }
-
- public override IDeepCloneable Clone(Cloner cloner) {
- return new LinearProgrammingProblemDefinitionScript(this, cloner);
- }
-
- public bool BuildModel(Solver solver) => CompiledProblemDefinition.BuildModel(solver);
-
- public void Analyze(Solver solver, ResultCollection results) => CompiledProblemDefinition.Analyze(solver, results);
- }
-}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblemDefintion.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblemDefintion.cs (revision 16404)
+++ (revision )
@@ -1,35 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using Google.OrTools.LinearSolver;
-using HeuristicLab.Problems.Programmable;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
-
- public class LinearProgrammingProblemDefintion : CompiledProblemDefinition {
-
- public void BuildModel(Solver solver) {
- }
-
- public override void Initialize() {
- }
- }
-}
Index: anches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProblemDefinitionScriptException.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProblemDefinitionScriptException.cs (revision 16404)
+++ (revision )
@@ -1,42 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Runtime.Serialization;
-
-namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems {
-
- [Serializable]
- public class ProblemDefinitionScriptException : Exception {
-
- public ProblemDefinitionScriptException() {
- }
-
- public ProblemDefinitionScriptException(string message) : base(message) {
- }
-
- public ProblemDefinitionScriptException(string message, Exception inner) : base(message, inner) {
- }
-
- protected ProblemDefinitionScriptException(SerializationInfo info, StreamingContext context)
- : base(info, context) { }
- }
-}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProgrammingProblemDefinition.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProgrammingProblemDefinition.cs (revision 16405)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProgrammingProblemDefinition.cs (revision 16405)
@@ -0,0 +1,150 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Linq;
+using System.Reflection;
+using Google.OrTools.LinearSolver;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.Programmable;
+using HeuristicLab.Scripting;
+
+namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
+
+ [Item("Programmable Linear/Mixed Integer Programming Problem Definition",
+ "Script that defines the model and evaluates the solution for a linear/mixed integer programming problem.")]
+ [StorableClass]
+ public sealed class ProgrammableLinearProgrammingProblemDefinition : Script, ILinearProgrammingProblemDefinition,
+ IStorableContent {
+ private readonly object compileLock = new object();
+
+ [Storable] private readonly VariableStore variableStore;
+
+ [Storable] private bool codeChanged;
+
+ private volatile ILinearProgrammingProblemDefinition compiledProblemDefinition;
+
+ public ProgrammableLinearProgrammingProblemDefinition()
+ : base(ScriptTemplates.CompiledLinearProgrammingProblemDefinition) {
+ Name = "Programmable Linear/Mixed Integer Programming Problem Definition";
+ variableStore = new VariableStore();
+ }
+
+ [StorableConstructor]
+ private ProgrammableLinearProgrammingProblemDefinition(bool deserializing) : base(deserializing) {
+ }
+
+ private ProgrammableLinearProgrammingProblemDefinition(ProgrammableLinearProgrammingProblemDefinition original,
+ Cloner cloner) : base(original, cloner) {
+ variableStore = cloner.Clone(original.variableStore);
+ codeChanged = original.codeChanged;
+ }
+
+ public event EventHandler ProblemDefinitionChanged;
+
+ public string Filename { get; set; }
+ public dynamic Instance => compiledProblemDefinition;
+ public VariableStore VariableStore => variableStore;
+
+ private ILinearProgrammingProblemDefinition CompiledProblemDefinition {
+ get {
+ // double checked locking pattern
+ if (compiledProblemDefinition == null) {
+ lock (compileLock) {
+ if (compiledProblemDefinition == null) {
+ if (codeChanged)
+ throw new ProblemDefinitionScriptException("The code has been changed, but was not recompiled.");
+ Compile(false);
+ }
+ }
+ }
+
+ return compiledProblemDefinition;
+ }
+ }
+
+ private bool SuppressEvents { get; set; }
+
+ public void Analyze(Solver solver, ResultCollection results) => CompiledProblemDefinition.Analyze(solver, results);
+
+ public void BuildModel(Solver solver) => CompiledProblemDefinition.BuildModel(solver);
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ return new ProgrammableLinearProgrammingProblemDefinition(this, cloner);
+ }
+
+ public override Assembly Compile() => Compile(true);
+
+ protected override void OnCodeChanged() {
+ base.OnCodeChanged();
+ compiledProblemDefinition = null;
+ codeChanged = true;
+ }
+
+ private Assembly Compile(bool fireChanged) {
+ var assembly = base.Compile();
+ var types = assembly.GetTypes();
+ if (!types.Any(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)))
+ throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." + Environment.NewLine +
+ "The problem definition must be a subclass of CompiledProblemDefinition.");
+ if (types.Count(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)) > 1)
+ throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." + Environment.NewLine +
+ "Only one subclass of CompiledProblemDefinition is allowed.");
+
+ CompiledProblemDefinition inst;
+ try {
+ inst = (CompiledProblemDefinition)Activator.CreateInstance(types.Single(x =>
+ typeof(CompiledProblemDefinition).IsAssignableFrom(x)));
+ } catch (Exception e) {
+ compiledProblemDefinition = null;
+ throw new ProblemDefinitionScriptException(
+ "Instantiating the problem definition failed." + Environment.NewLine + "Check your default constructor.", e);
+ }
+
+ try {
+ inst.vars = new Variables(VariableStore);
+ inst.Initialize();
+ } catch (Exception e) {
+ compiledProblemDefinition = null;
+ throw new ProblemDefinitionScriptException(
+ "Initializing the problem definition failed." + Environment.NewLine + "Check your Initialize() method.", e);
+ }
+
+ try {
+ compiledProblemDefinition = (ILinearProgrammingProblemDefinition)inst;
+ if (fireChanged) OnProblemDefinitionChanged();
+ } catch (Exception e) {
+ compiledProblemDefinition = null;
+ throw new ProblemDefinitionScriptException(
+ "Using the problem definition in the problem failed." + Environment.NewLine +
+ "Examine this error message carefully (often there is an issue with the defined encoding).", e);
+ }
+
+ codeChanged = false;
+ return assembly;
+ }
+
+ private void OnProblemDefinitionChanged() => ProblemDefinitionChanged?.Invoke(this, EventArgs.Empty);
+ }
+}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/CompiledLinearProgrammingProblemDefinition.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/CompiledLinearProgrammingProblemDefinition.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/CompiledLinearProgrammingProblemDefinition.cs (revision 16405)
@@ -6,7 +6,5 @@
using HeuristicLab.Core;
using HeuristicLab.Data;
-using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems;
using HeuristicLab.Optimization;
-using HeuristicLab.Problems.Programmable;
using Variable = Google.OrTools.LinearSolver.Variable;
@@ -22,6 +20,7 @@
}
- public bool BuildModel(Solver solver) {
+ public void BuildModel(Solver solver) {
// Use vars.yourVariable to access variables in the variable store i.e. yourVariable
+ // How to define a model using Google OR-Tools: https://developers.google.com/optimization/introduction/cs
// Example model taken from https://developers.google.com/optimization/mip/integer_opt
// Define the decision variables
@@ -32,10 +31,9 @@
// Define the objective
solver.Maximize(x + 10 * y);
- return true;
}
public void Analyze(Solver solver, ResultCollection results) {
// Use vars.yourVariable to access variables in the variable store i.e. yourVariable
- // Write or update results given the solution variables of the decision variables
+ // Write or update results given the solution values of the decision variables
results.AddOrUpdateResult("x", new DoubleValue(x.SolutionValue()));
results.AddOrUpdateResult("y", new DoubleValue(y.SolutionValue()));
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.Designer.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.Designer.cs (revision 16405)
@@ -60,18 +60,18 @@
///
- /// Looks up a localized string similar to using Google.OrTools.LinearSolver;
+ /// Looks up a localized string similar to using System;
+ ///using System.Linq;
+ ///using System.Collections.Generic;
+ ///using Google.OrTools.LinearSolver;
+ ///using HeuristicLab.Common;
+ ///using HeuristicLab.Core;
///using HeuristicLab.Data;
///using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems;
///using HeuristicLab.Optimization;
- ///using HeuristicLab.Problems.Programmable;
+ ///using Variable = Google.OrTools.LinearSolver.Variable;
///
///namespace HeuristicLab.MathematicalOptimization.LinearProgramming {
- /// public class CompiledLinearProgrammingProblemDefinition : CompiledProblemDefinition, ILinearProgrammingProblemDefinition {
///
- /// private Variable x;
- /// private Variable y;
- ///
- /// public override void Initialize() {
- /// // [rest of string was truncated]";.
+ /// public class CompiledLinearProgrammingProblemDefinition : CompiledProblemDefinition, ILi [rest of string was truncated]";.
///
internal static string CompiledLinearProgrammingProblemDefinition {
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.resx
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.resx (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.resx (revision 16405)
@@ -60,6 +60,6 @@
: and then encoded with base64 encoding.
-->
-
-
+
+
@@ -120,5 +120,5 @@
- CompiledLinearProgrammingProblemDefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
+ compiledlinearprogrammingproblemdefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Plugin.cs.frame
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Plugin.cs.frame (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Plugin.cs.frame (revision 16405)
@@ -28,13 +28,9 @@
[PluginFile("HeuristicLab.MathematicalOptimization-3.3.dll", PluginFileType.Assembly)]
[PluginDependency("HeuristicLab.Analysis", "3.3")]
- [PluginDependency("HeuristicLab.CodeEditor", "3.4")]
[PluginDependency("HeuristicLab.Collections", "3.3")]
[PluginDependency("HeuristicLab.Common", "3.3")]
[PluginDependency("HeuristicLab.Common.Resources", "3.3")]
[PluginDependency("HeuristicLab.Core", "3.3")]
- [PluginDependency("HeuristicLab.Core.Views", "3.3")]
[PluginDependency("HeuristicLab.Data", "3.3")]
- [PluginDependency("HeuristicLab.MainForm", "3.3")]
- [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
[PluginDependency("HeuristicLab.Optimization", "3.3")]
[PluginDependency("HeuristicLab.OrTools", "6.10")]
@@ -43,5 +39,4 @@
[PluginDependency("HeuristicLab.Problems.Programmable", "3.3")]
[PluginDependency("HeuristicLab.Scripting", "3.3")]
- [PluginDependency("HeuristicLab.Scripting.Views", "3.3")]
public class HeuristicLabMathematicalOptimizationPlugin : PluginBase {
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.Designer.cs
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.Designer.cs (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.Designer.cs (revision 16405)
@@ -13,5 +13,5 @@
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
@@ -33,16 +33,4 @@
set {
this["ScipLibraryName"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("gurobi80.dll")]
- public string GurobiLibraryName {
- get {
- return ((string)(this["GurobiLibraryName"]));
- }
- set {
- this["GurobiLibraryName"] = value;
}
}
@@ -71,4 +59,16 @@
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("gurobi81.dll")]
+ public string GurobiLibraryName {
+ get {
+ return ((string)(this["GurobiLibraryName"]));
+ }
+ set {
+ this["GurobiLibraryName"] = value;
+ }
+ }
}
}
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.settings
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.settings (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Properties/Settings.settings (revision 16405)
@@ -6,7 +6,4 @@
scip.dll
-
- gurobi80.dll
-
cplex1280.dll
@@ -15,4 +12,7 @@
glpk_4_65.dll
+
+ gurobi81.dll
+
Index: /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/app.config
===================================================================
--- /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/app.config (revision 16404)
+++ /branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/app.config (revision 16405)
@@ -11,7 +11,4 @@
scip.dll
-
- gurobi81.dll
-
cplex1280.dll
@@ -20,4 +17,7 @@
glpk_4_65.dll
+
+ gurobi81.dll
+