Changeset 16582 for branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProblemDefinition.cs
- Timestamp:
- 01/29/19 17:45:06 (5 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/2931_OR-Tools_LP_MIP/HeuristicLab.MathematicalOptimization/3.3/LinearProgramming/Problems/ProgrammableLinearProblemDefinition.cs
r16581 r16582 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.ExactOptimization.LinearProgramming.Templates; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 32 using HeuristicLab.Scripting; 32 33 33 namespace HeuristicLab. MathematicalOptimization.LinearProgramming {34 namespace HeuristicLab.ExactOptimization.LinearProgramming { 34 35 35 [Item("Programmable Linear /Mixed Integer Programming Problem Definition",36 "Script that defines the model and evaluates the solutionfor a linear/mixed integer programming problem.")]36 [Item("Programmable Linear Problem Definition (LP, MIP)", 37 "Script that defines the model for a linear/mixed integer programming problem.")] 37 38 [StorableClass] 38 public sealed class ProgrammableLinearPro grammingProblemDefinition : Script, ILinearProgrammingProblemDefinition,39 public sealed class ProgrammableLinearProblemDefinition : Script, ILinearProblemDefinition, 39 40 IStorableContent { 40 41 private readonly object compileLock = new object(); 41 42 42 [Storable] private readonly VariableStore variableStore; 43 [Storable] 44 private readonly VariableStore variableStore; 43 45 44 [Storable] private bool codeChanged; 46 [Storable] 47 private bool codeChanged; 45 48 46 private volatile ILinearPro grammingProblemDefinition compiledProblemDefinition;49 private volatile ILinearProblemDefinition compiledProblemDefinition; 47 50 48 public ProgrammableLinearPro grammingProblemDefinition()49 : base(ScriptTemplates.CompiledLinearPro grammingProblemDefinition) {50 Name = "Programmable Linear /Mixed Integer ProgrammingProblem Definition";51 public ProgrammableLinearProblemDefinition() 52 : base(ScriptTemplates.CompiledLinearProblemDefinition) { 53 Name = "Programmable Linear Problem Definition"; 51 54 variableStore = new VariableStore(); 52 55 } 53 56 54 57 [StorableConstructor] 55 private ProgrammableLinearPro grammingProblemDefinition(bool deserializing) : base(deserializing) {58 private ProgrammableLinearProblemDefinition(bool deserializing) : base(deserializing) { 56 59 } 57 60 58 private ProgrammableLinearPro grammingProblemDefinition(ProgrammableLinearProgrammingProblemDefinition original,61 private ProgrammableLinearProblemDefinition(ProgrammableLinearProblemDefinition original, 59 62 Cloner cloner) : base(original, cloner) { 60 63 variableStore = cloner.Clone(original.variableStore); … … 68 71 public VariableStore VariableStore => variableStore; 69 72 70 private ILinearPro grammingProblemDefinition CompiledProblemDefinition {73 private ILinearProblemDefinition CompiledProblemDefinition { 71 74 get { 72 75 // double checked locking pattern … … 85 88 } 86 89 87 private bool SuppressEvents { get; set; }88 89 90 public void Analyze(Solver solver, ResultCollection results) => CompiledProblemDefinition.Analyze(solver, results); 90 91 … … 92 93 93 94 public override IDeepCloneable Clone(Cloner cloner) { 94 return new ProgrammableLinearPro grammingProblemDefinition(this, cloner);95 return new ProgrammableLinearProblemDefinition(this, cloner); 95 96 } 96 97 … … 108 109 if (!types.Any(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x))) 109 110 throw new ProblemDefinitionScriptException("The compiled code doesn't contain a problem definition." + Environment.NewLine + 110 "The problem definition must be a subclass of CompiledProblemDefinition.");111 $"The problem definition must be a subclass of {nameof(CompiledProblemDefinition)} and implement {nameof(ILinearProblemDefinition)}."); 111 112 if (types.Count(x => typeof(CompiledProblemDefinition).IsAssignableFrom(x)) > 1) 112 113 throw new ProblemDefinitionScriptException("The compiled code contains multiple problem definitions." + Environment.NewLine + 113 "Only one subclass of CompiledProblemDefinitionis allowed.");114 $"Only one subclass of {nameof(CompiledProblemDefinition)} is allowed."); 114 115 115 116 CompiledProblemDefinition inst; … … 133 134 134 135 try { 135 compiledProblemDefinition = (ILinearPro grammingProblemDefinition)inst;136 compiledProblemDefinition = (ILinearProblemDefinition)inst; 136 137 if (fireChanged) OnProblemDefinitionChanged(); 137 138 } catch (Exception e) { … … 139 140 throw new ProblemDefinitionScriptException( 140 141 "Using the problem definition in the problem failed." + Environment.NewLine + 141 "Examine this error message carefully (often there is an issue with the defined encoding).", e);142 "Examine this error message carefully.", e); 142 143 } 143 144
Note: See TracChangeset
for help on using the changeset viewer.