Changeset 16172 for branches/2931_OR-Tools_LP_MIP
- Timestamp:
- 09/21/18 09:50:12 (6 years ago)
- Location:
- branches/2931_OR-Tools_LP_MIP
- Files:
-
- 19 added
- 4 deleted
- 7 edited
- 11 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/2931_OR-Tools_LP_MIP/HeuristicLab.ExtLibs.sln
r16070 r16172 75 75 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.IGraph-0.8.0-pre", "HeuristicLab.ExtLibs\HeuristicLab.Igraph\0.8.0-pre\HeuristicLab.Igraph-0.8.0-pre\HeuristicLab.IGraph-0.8.0-pre.csproj", "{088D34F2-32EA-43FF-BAA8-22428D5B66BE}" 76 76 EndProject 77 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.OrTools-6. 8.0-pre", "HeuristicLab.ExtLibs\HeuristicLab.OrTools\6.8.0-pre\HeuristicLab.OrTools-6.8.0-pre\HeuristicLab.OrTools-6.8.0-pre.csproj", "{AEC895BC-C519-49D3-9A94-6B1C71AD6671}"77 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.OrTools-6.9.0-pre", "HeuristicLab.ExtLibs\HeuristicLab.OrTools\6.9.0-pre\HeuristicLab.OrTools-6.9.0-pre\HeuristicLab.OrTools-6.9.0-pre.csproj", "{AEC895BC-C519-49D3-9A94-6B1C71AD6671}" 78 78 EndProject 79 79 Global -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.ExtLibs/HeuristicLab.OrTools/6.9.0-pre/HeuristicLab.OrTools-6.9.0-pre/HeuristicLab.OrTools-6.9.0-pre.csproj
r16138 r16172 9 9 <AppDesignerFolder>Properties</AppDesignerFolder> 10 10 <RootNamespace>HeuristicLab.OrTools</RootNamespace> 11 <AssemblyName>HeuristicLab.OrTools-6. 8.0-pre</AssemblyName>11 <AssemblyName>HeuristicLab.OrTools-6.9.0-pre</AssemblyName> 12 12 <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> 13 13 <FileAlignment>512</FileAlignment> … … 128 128 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 129 129 </Content> 130 <Content Include="Google.OrTools.import.dll">131 <CopyToOutputDirectory>Always</CopyToOutputDirectory>132 </Content>133 <Content Include="Google.OrTools.import.pdb">134 <CopyToOutputDirectory>Always</CopyToOutputDirectory>135 </Content>136 130 <Content Include="Google.OrTools_version.txt"> 137 131 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 138 132 </Content> 139 133 <Content Include="Google.Protobuf.dll"> 134 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 135 </Content> 136 <Content Include="runtime.win-x64.Google.OrTools.dll"> 140 137 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 141 138 </Content> -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.ExtLibs/HeuristicLab.OrTools/6.9.0-pre/HeuristicLab.OrTools-6.9.0-pre/Plugin.cs.frame
r16138 r16172 24 24 25 25 namespace HeuristicLab.OrTools { 26 [Plugin("HeuristicLab.OrTools", "Provides functionality of Google OR-Tools in HeuristicLab. Requires Windows 64-bit", "6. 8.0.$WCREV$")]27 [PluginFile("HeuristicLab.OrTools-6. 8.0-pre.dll", PluginFileType.Assembly)]26 [Plugin("HeuristicLab.OrTools", "Provides functionality of Google OR-Tools in HeuristicLab. Requires Windows 64-bit", "6.9.0.$WCREV$")] 27 [PluginFile("HeuristicLab.OrTools-6.9.0-pre.dll", PluginFileType.Assembly)] 28 28 [PluginFile("Google.OrTools.dll", PluginFileType.Assembly)] 29 29 [PluginFile("Google.OrTools-license.txt", PluginFileType.License)] 30 [PluginFile(" Google.OrTools.import.dll", PluginFileType.NativeDll)]30 [PluginFile("runtime.win-x64.Google.OrTools.dll", PluginFileType.NativeDll)] 31 31 [PluginFile("Google.OrTools_version.txt", PluginFileType.Data)] 32 32 [PluginFile("glpk_4_65.dll", PluginFileType.NativeDll)] -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.ExtLibs/HeuristicLab.OrTools/6.9.0-pre/HeuristicLab.OrTools-6.9.0-pre/Properties/AssemblyInfo.cs
r16138 r16172 54 54 // [assembly: AssemblyVersion("1.0.*")] 55 55 [assembly: AssemblyVersion("6.8.0.0")] 56 [assembly: AssemblyFileVersion("6.8.0.16 070")]56 [assembly: AssemblyFileVersion("6.8.0.16138")] -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/HeuristicLab.MathematicalOptimization-3.3.csproj
r16138 r16172 115 115 <HintPath>..\..\bin\Google.OrTools.dll</HintPath> 116 116 </Reference> 117 <Reference Include=" Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">117 <Reference Include="HeuristicLab.OrTools-6.9.0-pre, Version=6.8.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 118 118 <SpecificVersion>False</SpecificVersion> 119 <HintPath>..\..\bin\Google.Protobuf.dll</HintPath> 120 <Private>False</Private> 119 <HintPath>..\..\bin\HeuristicLab.OrTools-6.9.0-pre.dll</HintPath> 121 120 </Reference> 122 121 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86"> … … 127 126 <Reference Include="System.Core" /> 128 127 <Reference Include="System.Data" /> 129 </ItemGroup> 130 <ItemGroup> 128 <Reference Include="System.Drawing" /> 129 <Reference Include="System.Windows.Forms" /> 130 <Reference Include="System.Xml" /> 131 </ItemGroup> 132 <ItemGroup> 133 <Compile Include="LinearProgramming\Algorithms\BopSolver.cs" /> 134 <Compile Include="LinearProgramming\Algorithms\CoinOrSolver.cs" /> 135 <Compile Include="LinearProgramming\Algorithms\GlopSolver.cs" /> 136 <Compile Include="LinearProgramming\Algorithms\GlpkSolver.cs" /> 137 <Compile Include="LinearProgramming\Algorithms\LinearProgrammingType.cs" /> 138 <Compile Include="LinearProgramming\Algorithms\ScipSolver.cs" /> 131 139 <Compile Include="LinearProgramming\BasisStatus.cs" /> 140 <Compile Include="LinearProgramming\Algorithms\CplexSolver.cs" /> 141 <Compile Include="LinearProgramming\Algorithms\GurobiSolver.cs" /> 142 <Compile Include="LinearProgramming\Algorithms\ISolver.cs" /> 143 <Compile Include="LinearProgramming\Problems\ILinearProgrammingProblemDefinition.cs" /> 144 <Compile Include="LinearProgramming\Algorithms\LinearProgrammingAlgorithm.cs" /> 145 <Compile Include="LinearProgramming\Problems\LinearProgrammingProblem.cs" /> 132 146 <Compile Include="LinearProgramming\LinearSolverExtensions.cs" /> 133 147 <Compile Include="LinearProgramming\LinearSolver.cs" /> 148 <Compile Include="LinearProgramming\Problems\LinearProgrammingProblemDefintion.cs" /> 134 149 <Compile Include="LinearProgramming\OptimizationProblemType.cs" /> 150 <Compile Include="LinearProgramming\Problems\ProblemDefinitionScriptException.cs" /> 151 <Compile Include="LinearProgramming\Algorithms\Solver.cs" /> 152 <Compile Include="LinearProgramming\Views\LinearProgrammingProblemDefinitionScriptView.cs"> 153 <SubType>UserControl</SubType> 154 </Compile> 155 <Compile Include="LinearProgramming\Views\LinearProgrammingProblemDefinitionScriptView.Designer.cs"> 156 <DependentUpon>LinearProgrammingProblemDefinitionScriptView.cs</DependentUpon> 157 </Compile> 135 158 <Compile Include="LinearProgramming\ResultStatus.cs" /> 159 <Compile Include="LinearProgramming\Views\LinearProgrammingProblemView.cs"> 160 <SubType>UserControl</SubType> 161 </Compile> 162 <Compile Include="LinearProgramming\Views\LinearProgrammingProblemView.Designer.cs"> 163 <DependentUpon>LinearProgrammingProblemView.cs</DependentUpon> 164 </Compile> 165 <Compile Include="LinearProgramming\Problems\LinearProgrammingProblemDefinitionScript.cs" /> 166 <Compile Include="LinearProgramming\Templates\CompiledLinearProgrammingProblemDefinition.cs" /> 167 <Compile Include="LinearProgramming\Templates\ScriptTemplates.Designer.cs"> 168 <AutoGen>True</AutoGen> 169 <DesignTime>True</DesignTime> 170 <DependentUpon>ScriptTemplates.resx</DependentUpon> 171 </Compile> 136 172 <Compile Include="Properties\AssemblyInfo.cs" /> 137 173 <None Include="Plugin.cs.frame" /> … … 142 178 <None Include="HeuristicLab.snk" /> 143 179 </ItemGroup> 144 <ItemGroup /> 180 <ItemGroup> 181 <ProjectReference Include="..\..\HeuristicLab.Clients.OKB\3.3\HeuristicLab.Clients.OKB-3.3.csproj"> 182 <Project>{73857A9C-9706-4B72-8D9C-210B5B6A5691}</Project> 183 <Name>HeuristicLab.Clients.OKB-3.3</Name> 184 </ProjectReference> 185 <ProjectReference Include="..\..\HeuristicLab.CodeEditor\3.4\HeuristicLab.CodeEditor-3.4.csproj"> 186 <Project>{C38691AE-ECB4-489A-A05D-B035554E0168}</Project> 187 <Name>HeuristicLab.CodeEditor-3.4</Name> 188 </ProjectReference> 189 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 190 <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project> 191 <Name>HeuristicLab.Collections-3.3</Name> 192 </ProjectReference> 193 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj"> 194 <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project> 195 <Name>HeuristicLab.Common.Resources-3.3</Name> 196 </ProjectReference> 197 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> 198 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 199 <Name>HeuristicLab.Common-3.3</Name> 200 </ProjectReference> 201 <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj"> 202 <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project> 203 <Name>HeuristicLab.Core.Views-3.3</Name> 204 </ProjectReference> 205 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 206 <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project> 207 <Name>HeuristicLab.Core-3.3</Name> 208 </ProjectReference> 209 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> 210 <Project>{BBAB9DF5-5EF3-4BA8-ADE9-B36E82114937}</Project> 211 <Name>HeuristicLab.Data-3.3</Name> 212 </ProjectReference> 213 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj"> 214 <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project> 215 <Name>HeuristicLab.MainForm.WindowsForms-3.3</Name> 216 </ProjectReference> 217 <ProjectReference Include="..\..\HeuristicLab.MainForm\3.3\HeuristicLab.MainForm-3.3.csproj"> 218 <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project> 219 <Name>HeuristicLab.MainForm-3.3</Name> 220 </ProjectReference> 221 <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj"> 222 <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project> 223 <Name>HeuristicLab.Optimization.Operators-3.3</Name> 224 </ProjectReference> 225 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 226 <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project> 227 <Name>HeuristicLab.Optimization-3.3</Name> 228 </ProjectReference> 229 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 230 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> 231 <Name>HeuristicLab.Parameters-3.3</Name> 232 </ProjectReference> 233 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> 234 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> 235 <Name>HeuristicLab.Persistence-3.3</Name> 236 </ProjectReference> 237 <ProjectReference Include="..\..\HeuristicLab.Problems.Programmable\3.3\HeuristicLab.Problems.Programmable-3.3.csproj"> 238 <Project>{EE07BFF8-B23D-41F5-8AD7-AC9598D7A2C9}</Project> 239 <Name>HeuristicLab.Problems.Programmable-3.3</Name> 240 </ProjectReference> 241 <ProjectReference Include="..\..\HeuristicLab.Scripting.Views\3.3\HeuristicLab.Scripting.Views-3.3.csproj"> 242 <Project>{0C2917C8-7AA8-4E18-800A-C4D064F992ED}</Project> 243 <Name>HeuristicLab.Scripting.Views-3.3</Name> 244 </ProjectReference> 245 <ProjectReference Include="..\..\HeuristicLab.Scripting\3.3\HeuristicLab.Scripting-3.3.csproj"> 246 <Project>{21977CC3-1757-4B3B-87BD-FF817AAA900F}</Project> 247 <Name>HeuristicLab.Scripting-3.3</Name> 248 </ProjectReference> 249 </ItemGroup> 250 <ItemGroup> 251 <EmbeddedResource Include="LinearProgramming\Templates\ScriptTemplates.resx"> 252 <Generator>ResXFileCodeGenerator</Generator> 253 <LastGenOutput>ScriptTemplates.Designer.cs</LastGenOutput> 254 </EmbeddedResource> 255 <EmbeddedResource Include="LinearProgramming\Views\LinearProgrammingProblemView.resx"> 256 <DependentUpon>LinearProgrammingProblemView.cs</DependentUpon> 257 </EmbeddedResource> 258 </ItemGroup> 145 259 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 146 260 <PropertyGroup> -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ILinearProgrammingProblemDefinition.cs
r16138 r16172 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using HeuristicLab. Core;22 using Google.OrTools.LinearSolver; 23 using HeuristicLab.Optimization; 24 24 25 namespace HeuristicLab.Optimization { 26 public interface ISingleObjectiveProblemDefinition : IProblemDefinition { 27 bool Maximization { get; } 28 double Evaluate(Individual individual, IRandom random); 29 void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random); 30 IEnumerable<Individual> GetNeighbors(Individual individual, IRandom random); 25 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems { 26 public interface ILinearProgrammingProblemDefinition { 27 void BuildModel(Solver solver); 28 void Analyze(Solver solver, ResultCollection results); 31 29 } 32 30 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/LinearProgrammingProblemDefinitionScript.cs
r16138 r16172 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 using System; 23 using System.Linq; 24 using System.Reflection; 25 using Google.OrTools.LinearSolver; 23 26 using HeuristicLab.Common; 24 27 using HeuristicLab.Core; 25 28 using HeuristicLab.Optimization; 26 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Problems.Programmable; 31 using HeuristicLab.Scripting; 27 32 28 namespace HeuristicLab. Problems.Programmable{33 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems { 29 34 [Item("Single-objective Problem Definition Script", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")] 30 35 [StorableClass] 31 public sealed class SingleObjectiveProblemDefinitionScript : ProblemDefinitionScript, ISingleObjectiveProblemDefinition, IStorableContent { 36 public sealed class LinearProgrammingProblemDefinitionScript : Script, ILinearProgrammingProblemDefinition, IStorableContent { 37 protected bool SuppressEvents { get; set; } 38 39 [Storable] 40 private VariableStore variableStore; 41 public VariableStore VariableStore => variableStore; 42 43 [Storable] 44 private bool codeChanged; 45 46 [StorableConstructor] 47 protected LinearProgrammingProblemDefinitionScript(bool deserializing) : base(deserializing) { } 48 protected LinearProgrammingProblemDefinitionScript(LinearProgrammingProblemDefinitionScript original, Cloner cloner) 49 : base(original, cloner) { 50 variableStore = cloner.Clone(original.variableStore); 51 codeChanged = original.codeChanged; 52 } 53 54 public LinearProgrammingProblemDefinitionScript() 55 : base(ScriptTemplates.CompiledLinearProgrammingProblemDefinition) { 56 variableStore = new VariableStore(); 57 } 58 59 private readonly object compileLock = new object(); 60 private volatile ILinearProgrammingProblemDefinition compiledProblemDefinition; 61 protected ILinearProgrammingProblemDefinition CompiledProblemDefinition { 62 get { 63 // double checked locking pattern 64 if (compiledProblemDefinition == null) { 65 lock (compileLock) { 66 if (compiledProblemDefinition == null) { 67 if (codeChanged) throw new ProblemDefinitionScriptException("The code has been changed, but was not recompiled."); 68 Compile(false); 69 } 70 } 71 } 72 return compiledProblemDefinition; 73 } 74 } 75 public dynamic Instance => compiledProblemDefinition; 76 77 public override Assembly Compile() { 78 return Compile(true); 79 } 80 81 private Assembly Compile(bool fireChanged) { 82 var assembly = base.Compile(); 83 var types = assembly.GetTypes(); 84 if (!types.Any(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x))) 85 throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." + Environment.NewLine + "The problem definition must be a subclass of CompiledProblemDefinition."); 86 if (types.Count(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)) > 1) 87 throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." + Environment.NewLine + "Only one subclass of CompiledProblemDefinition is allowed."); 88 89 CompiledProblemDefinition inst; 90 try { 91 inst = (CompiledProblemDefinition)Activator.CreateInstance(types.Single(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x))); 92 } catch (Exception e) { 93 compiledProblemDefinition = null; 94 throw new ProblemDefinitionScriptException("Instantiating the problem definition failed." + Environment.NewLine + "Check your default constructor.", e); 95 } 96 97 try { 98 inst.vars = new Variables(VariableStore); 99 inst.Initialize(); 100 } catch (Exception e) { 101 compiledProblemDefinition = null; 102 throw new ProblemDefinitionScriptException("Initializing the problem definition failed." + Environment.NewLine + "Check your Initialize() method.", e); 103 } 104 105 try { 106 compiledProblemDefinition = (ILinearProgrammingProblemDefinition)inst; 107 if (fireChanged) OnProblemDefinitionChanged(); 108 } catch (Exception e) { 109 compiledProblemDefinition = null; 110 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); 111 } 112 113 codeChanged = false; 114 return assembly; 115 } 116 117 protected override void OnCodeChanged() { 118 base.OnCodeChanged(); 119 compiledProblemDefinition = null; 120 codeChanged = true; 121 } 122 123 public event EventHandler ProblemDefinitionChanged; 124 private void OnProblemDefinitionChanged() { 125 var handler = ProblemDefinitionChanged; 126 if (handler != null) handler(this, EventArgs.Empty); 127 } 128 32 129 public string Filename { get; set; } 33 130 34 p rivate new ISingleObjectiveProblemDefinition CompiledProblemDefinition{35 get { return (ISingleObjectiveProblemDefinition)base.CompiledProblemDefinition; }131 public override IDeepCloneable Clone(Cloner cloner) { 132 return new LinearProgrammingProblemDefinitionScript(this, cloner); 36 133 } 37 134 38 [StorableConstructor] 39 private SingleObjectiveProblemDefinitionScript(bool deserializing) : base(deserializing) { } 40 private SingleObjectiveProblemDefinitionScript(SingleObjectiveProblemDefinitionScript original, Cloner cloner) : base(original, cloner) { } 41 public SingleObjectiveProblemDefinitionScript() : base(ScriptTemplates.CompiledSingleObjectiveProblemDefinition) { } 135 public void BuildModel(Solver solver) => CompiledProblemDefinition.BuildModel(solver); 42 136 43 public override IDeepCloneable Clone(Cloner cloner) { 44 return new SingleObjectiveProblemDefinitionScript(this, cloner); 45 } 46 47 bool ISingleObjectiveProblemDefinition.Maximization { 48 get { return CompiledProblemDefinition.Maximization; } 49 } 50 51 double ISingleObjectiveProblemDefinition.Evaluate(Individual individual, IRandom random) { 52 return CompiledProblemDefinition.Evaluate(individual, random); 53 } 54 55 void ISingleObjectiveProblemDefinition.Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) { 56 CompiledProblemDefinition.Analyze(individuals, qualities, results, random); 57 } 58 IEnumerable<Individual> ISingleObjectiveProblemDefinition.GetNeighbors(Individual individual, IRandom random) { 59 return CompiledProblemDefinition.GetNeighbors(individual, random); 60 } 137 public void Analyze(Solver solver, ResultCollection results) => CompiledProblemDefinition.Analyze(solver, results); 61 138 } 62 139 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProblemDefinitionScriptException.cs
r16138 r16172 23 23 using System.Runtime.Serialization; 24 24 25 namespace HeuristicLab. Problems.Programmable{25 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Problems { 26 26 [Serializable] 27 27 public class ProblemDefinitionScriptException : Exception { -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/CompiledLinearProgrammingProblemDefinition.cs
r16138 r16172 1 using System; 2 using System.Linq; 3 using System.Collections.Generic; 4 using HeuristicLab.Common; 5 using HeuristicLab.Core; 1 using Google.OrTools.LinearSolver; 6 2 using HeuristicLab.Data; 7 using HeuristicLab.Encodings.BinaryVectorEncoding; 8 using HeuristicLab.Encodings.IntegerVectorEncoding; 9 using HeuristicLab.Encodings.RealVectorEncoding; 10 using HeuristicLab.Encodings.PermutationEncoding; 11 using HeuristicLab.Encodings.LinearLinkageEncoding; 12 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 3 using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems; 13 4 using HeuristicLab.Optimization; 14 5 using HeuristicLab.Problems.Programmable; 15 6 16 namespace HeuristicLab.Problems.Programmable { 17 public class CompiledSingleObjectiveProblemDefinition : CompiledProblemDefinition, ISingleObjectiveProblemDefinition { 18 public bool Maximization { get { return false; } } 7 namespace HeuristicLab.MathematicalOptimization.LinearProgramming { 8 public class CompiledLinearProgrammingProblemDefinition : CompiledProblemDefinition, ILinearProgrammingProblemDefinition { 9 10 private Variable x; 11 private Variable y; 19 12 20 13 public override void Initialize() { 21 14 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 22 // Define the solution encoding which can also consist of multiple vectors, examples below23 //Encoding = new BinaryVectorEncoding("b", length: 5);24 //Encoding = new IntegerVectorEncoding("i", length: 5, min: 2, max: 14, step: 2);25 //Encoding = new RealVectorEncoding("r", length: 5, min: -1.0, max: 1.0);26 //Encoding = new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute);27 //Encoding = new LinearLinkageEncoding("l", length: 5);28 //Encoding = new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12);29 // The encoding can also be a combination30 //Encoding = new MultiEncoding()31 //.Add(new BinaryVectorEncoding("b", length: 5))32 //.Add(new IntegerVectorEncoding("i", length: 5, min: 2, max: 14, step: 4))33 //.Add(new RealVectorEncoding("r", length: 5, min: -1.0, max: 1.0))34 //.Add(new PermutationEncoding("p", length: 5, type: PermutationTypes.Absolute))35 //.Add(new LinearLinkageEncoding("l", length: 5))36 //.Add(new SymbolicExpressionTreeEncoding("s", new SimpleSymbolicExpressionGrammar(), 50, 12))37 ;38 15 // Add additional initialization code e.g. private variables that you need for evaluating 39 16 } 40 17 41 public double Evaluate(Individual individual, IRandom random) {18 public void BuildModel(Solver solver) { 42 19 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 43 var quality = 0.0; 44 //quality = individual.RealVector("r").Sum(x => x * x); 45 return quality; 20 // Example model taken from https://developers.google.com/optimization/mip/integer_opt 21 // Define the decision variables 22 x = solver.MakeIntVar(0, 3.5, "x"); 23 y = solver.MakeIntVar(0, double.PositiveInfinity, "y"); 24 // Define the constraints 25 solver.Add(x + 7 * y <= 17.5); 26 // Define the objective 27 solver.Maximize(x + 10 * y); 46 28 } 47 29 48 public void Analyze( Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {30 public void Analyze(Solver solver, ResultCollection results) { 49 31 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 50 // Write or update results given the range of vectors and resulting qualities 51 // Uncomment the following lines if you want to retrieve the best individual 52 53 //var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality); 54 //var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual; 55 56 //if (!results.ContainsKey("Best Solution")) { 57 // results.Add(new Result("Best Solution", typeof(RealVector))); 58 //} 59 //results["Best Solution"].Value = (IItem)best.RealVector("r").Clone(); 60 } 61 62 public IEnumerable<Individual> GetNeighbors(Individual individual, IRandom random) { 63 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 64 // Create new vectors, based on the given one that represent small changes 65 // This method is only called from move-based algorithms (Local Search, Simulated Annealing, etc.) 66 while (true) { 67 // Algorithm will draw only a finite amount of samples 68 // Change to a for-loop to return a concrete amount of neighbors 69 var neighbor = individual.Copy(); 70 // For instance, perform a single bit-flip in a binary parameter 71 //var bIndex = random.Next(neighbor.BinaryVector("b").Length); 72 //neighbor.BinaryVector("b")[bIndex] = !neighbor.BinaryVector("b")[bIndex]; 73 yield return neighbor; 74 } 32 // Write or update results given the solution variables of the decision variables 33 results.AddOrUpdateResult("x", new DoubleValue(x.SolutionValue())); 34 results.AddOrUpdateResult("y", new DoubleValue(y.SolutionValue())); 35 // The decision variables can also be retrieved from the solver 36 //results.AddOrUpdateResult("x", new DoubleValue(solver.LookupVariableOrNull("x").SolutionValue())); 37 //results.AddOrUpdateResult("y", new DoubleValue(solver.LookupVariableOrNull("y").SolutionValue())); 75 38 } 76 39 … … 78 41 } 79 42 } 80 -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Templates/ScriptTemplates.resx
r11753 r16172 119 119 </resheader> 120 120 <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 121 <data name="CompiledMultiObjectiveProblemDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms"> 122 <value>CompiledMultiObjectiveProblemDefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> 123 </data> 124 <data name="CompiledSingleObjectiveProblemDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms"> 125 <value>CompiledSingleObjectiveProblemDefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> 121 <data name="CompiledLinearProgrammingProblemDefinition" type="System.Resources.ResXFileRef, System.Windows.Forms"> 122 <value>CompiledLinearProgrammingProblemDefinition.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> 126 123 </data> 127 124 </root> -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Views/LinearProgrammingProblemDefinitionScriptView.Designer.cs
r16138 r16172 21 21 22 22 23 namespace HeuristicLab.Problems.Programmable.Views { 24 partial class ProblemDefinitionScriptView { 23 using System.ComponentModel; 24 using System.Windows.Forms; 25 using HeuristicLab.Scripting.Views; 26 27 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Views { 28 partial class LinearProgrammingProblemDefinitionScriptView { 25 29 /// <summary> 26 30 /// Required designer variable. 27 31 /// </summary> 28 private System.ComponentModel.IContainer components = null;32 private IContainer components = null; 29 33 30 34 /// <summary> … … 46 50 /// </summary> 47 51 private void InitializeComponent() { 48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof( ProblemDefinitionScriptView));52 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LinearProgrammingProblemDefinitionScriptView)); 49 53 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 50 54 this.variableStoreView = new HeuristicLab.Scripting.Views.VariableStoreView(); … … 168 172 #endregion 169 173 170 private S ystem.Windows.Forms.SplitContainer splitContainer2;171 private Scripting.Views.VariableStoreView variableStoreView;174 private SplitContainer splitContainer2; 175 private VariableStoreView variableStoreView; 172 176 } 173 177 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Views/LinearProgrammingProblemDefinitionScriptView.cs
r16138 r16172 23 23 using System.Drawing; 24 24 using HeuristicLab.MainForm; 25 using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems; 26 using HeuristicLab.PluginInfrastructure; 25 27 using HeuristicLab.Scripting.Views; 26 28 27 namespace HeuristicLab. Problems.Programmable.Views {28 [View(" ProblemDefinitionScriptView")]29 [Content(typeof( ProblemDefinitionScript), IsDefaultView = true)]30 public partial class ProblemDefinitionScriptView : ScriptView {29 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Views { 30 [View("LinearProgrammingProblemDefinitionScriptView")] 31 [Content(typeof(LinearProgrammingProblemDefinitionScript), IsDefaultView = true)] 32 public partial class LinearProgrammingProblemDefinitionScriptView : ScriptView { 31 33 32 public new ProblemDefinitionScript Content {33 get { return (ProblemDefinitionScript)base.Content; }34 set { base.Content = value; }34 public new LinearProgrammingProblemDefinitionScript Content { 35 get => (LinearProgrammingProblemDefinitionScript)base.Content; 36 set => base.Content = value; 35 37 } 36 38 37 public ProblemDefinitionScriptView() {39 public LinearProgrammingProblemDefinitionScriptView() { 38 40 InitializeComponent(); 39 41 } … … 41 43 protected override void OnContentChanged() { 42 44 base.OnContentChanged(); 43 variableStoreView.Content = Content == null ? null : Content.VariableStore;45 variableStoreView.Content = Content?.VariableStore; 44 46 } 45 47 … … 53 55 base.Compile(); 54 56 } catch (ProblemDefinitionScriptException e) { 55 PluginInfrastructure.ErrorHandling.ShowErrorDialog(e);57 ErrorHandling.ShowErrorDialog(e); 56 58 return false; 57 59 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Views/LinearProgrammingProblemView.Designer.cs
r16138 r16172 20 20 #endregion 21 21 22 namespace HeuristicLab.Problems.Programmable.Views { 23 partial class SingleObjectiveProgrammableProblemView { 22 using System.ComponentModel; 23 24 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Views { 25 partial class LinearProgrammingProblemView { 24 26 /// <summary> 25 27 /// Required designer variable. 26 28 /// </summary> 27 private System.ComponentModel.IContainer components = null;29 private IContainer components = null; 28 30 29 31 /// <summary> … … 47 49 this.SuspendLayout(); 48 50 // 49 // ProgrammableProblemView51 // LinearProgrammingProblemView 50 52 // 51 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 52 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 53 this.Name = "ProgrammableProblemView"; 54 this.Size = new System.Drawing.Size(626, 413); 53 this.Name = "LinearProgrammingProblemView"; 54 this.Load += new System.EventHandler(this.LinearProgrammingProblemView_Load); 55 55 this.ResumeLayout(false); 56 56 -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Views/LinearProgrammingProblemView.cs
r16138 r16172 25 25 using HeuristicLab.MainForm; 26 26 using HeuristicLab.MainForm.WindowsForms; 27 using HeuristicLab.MathematicalOptimization.LinearProgramming.Problems; 27 28 28 namespace HeuristicLab. Problems.Programmable.Views {29 [View(" Single-Objective ScriptableProblem View")]30 [Content(typeof( SingleObjectiveProgrammableProblem), true)]31 public partial class SingleObjectiveProgrammableProblemView : ItemView {29 namespace HeuristicLab.MathematicalOptimization.LinearProgramming.Views { 30 [View("Linear Programming Problem View")] 31 [Content(typeof(LinearProgrammingProblem), true)] 32 public partial class LinearProgrammingProblemView : ItemView { 32 33 protected ViewHost ScriptView; 33 34 34 public new SingleObjectiveProgrammableProblem Content {35 get { return (SingleObjectiveProgrammableProblem)base.Content; }36 set { base.Content = value; }35 public new LinearProgrammingProblem Content { 36 get => (LinearProgrammingProblem)base.Content; 37 set => base.Content = value; 37 38 } 38 39 39 public SingleObjectiveProgrammableProblemView() {40 public LinearProgrammingProblemView() { 40 41 InitializeComponent(); 41 ScriptView = new ViewHost (){ ViewsLabelVisible = false, Dock = DockStyle.Fill };42 ScriptView = new ViewHost { ViewsLabelVisible = false, Dock = DockStyle.Fill }; 42 43 Controls.Add(ScriptView); 43 44 } … … 72 73 Caption = Content.Name; 73 74 } 75 76 private void LinearProgrammingProblemView_Load(object sender, EventArgs e) { 77 78 } 74 79 } 75 80 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/Plugin.cs.frame
r16070 r16172 25 25 [Plugin("HeuristicLab.MathematicalOptimization", "Provides support for mathematical optimization based on Google OR-Tools", "3.3.15.$WCREV$")] 26 26 [PluginFile("HeuristicLab.MathematicalOptimization-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.OrTools", "6.8.0")] 27 [PluginDependency("HeuristicLab.Core", "3.3")] 28 [PluginDependency("HeuristicLab.Collections", "3.3")] 29 [PluginDependency("HeuristicLab.Data", "3.3")] 30 [PluginDependency("HeuristicLab.Optimization", "3.3")] 31 [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")] 32 [PluginDependency("HeuristicLab.Problems.Programmable", "3.3")] 33 [PluginDependency("HeuristicLab.Scripting", "3.3")] 34 [PluginDependency("HeuristicLab.OrTools", "6.9")] 28 35 public class HeuristicLabMathematicalOptimizationPlugin : PluginBase { 29 36 } -
branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs
r15583 r16172 1 1 #region License Information 2 2 3 /* HeuristicLab 3 4 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 18 19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 20 */ 20 #endregion 21 22 #endregion License Information 21 23 22 24 using System; … … 30 32 31 33 namespace HeuristicLab.Problems.Programmable { 34 32 35 [Item("ProblemDefinitionScript", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")] 33 36 [StorableClass] … … 37 40 [Storable] 38 41 private VariableStore variableStore; 42 39 43 public VariableStore VariableStore { 40 44 get { return variableStore; } … … 46 50 [StorableConstructor] 47 51 protected ProblemDefinitionScript(bool deserializing) : base(deserializing) { } 52 48 53 protected ProblemDefinitionScript(ProblemDefinitionScript original, Cloner cloner) 49 54 : base(original, cloner) { … … 51 56 codeChanged = original.codeChanged; 52 57 } 58 53 59 protected ProblemDefinitionScript() 54 60 : base() { 55 61 variableStore = new VariableStore(); 56 62 } 63 57 64 protected ProblemDefinitionScript(string code) 58 65 : base(code) { … … 66 73 private readonly object compileLock = new object(); 67 74 private volatile IProblemDefinition compiledProblemDefinition; 75 68 76 protected IProblemDefinition CompiledProblemDefinition { 69 77 get { … … 80 88 } 81 89 } 90 82 91 public dynamic Instance { 83 92 get { return compiledProblemDefinition; } … … 131 140 132 141 public event EventHandler ProblemDefinitionChanged; 142 133 143 protected virtual void OnProblemDefinitionChanged() { 134 144 var handler = ProblemDefinitionChanged;
Note: See TracChangeset
for help on using the changeset viewer.