LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverNativeParameter.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Represents a solver-specific parameter that is passed to a
9/// solver adapter without being interpreted by the generic
10/// solver layer.
11/// </summary>
12[Serializable]
13[XmlType(TypeName = "solverNativeParameter")]
14public sealed class SolverNativeParameter
15{
16 /// <summary>
17 /// Initializes an empty native solver parameter.
18 /// </summary>
20 {
21 Name =
22 string.Empty;
23
24 Value =
25 string.Empty;
26 }
27
28 /// <summary>
29 /// Initializes a native solver parameter.
30 /// </summary>
31 /// <param name="name">
32 /// Native parameter name.
33 /// </param>
34 /// <param name="value">
35 /// Native parameter value represented using invariant text.
36 /// </param>
37 /// <param name="solverKind">
38 /// Solver to which the parameter applies.
39 /// </param>
41 string name,
42 string value,
43 SolverKind solverKind = SolverKind.Unknown)
44 : this()
45 {
46 Name =
47 name;
48
49 Value =
50 value;
51
53 solverKind;
54
56 }
57
58 /// <summary>
59 /// Gets or sets the solver to which the parameter applies.
60 /// </summary>
61 /// <remarks>
62 /// <see cref="Common.SolverKind.Unknown"/> means that the
63 /// selected adapter decides whether the parameter applies.
64 /// </remarks>
65 [XmlAttribute("solverKind")]
67 {
68 get;
69 set;
70 }
71
72 /// <summary>
73 /// Gets or sets the native solver parameter name.
74 /// </summary>
75 [XmlAttribute("name")]
76 public string Name
77 {
78 get;
79 set;
80 }
81
82 /// <summary>
83 /// Gets or sets the native solver parameter value.
84 /// </summary>
85 [XmlAttribute("value")]
86 public string Value
87 {
88 get;
89 set;
90 }
91
92 /// <summary>
93 /// Validates the native solver parameter.
94 /// </summary>
95 /// <exception cref="InvalidOperationException">
96 /// Thrown when the parameter name or value is empty.
97 /// </exception>
98 public void EnsureValid()
99 {
100 if (string.IsNullOrWhiteSpace(
101 Name))
102 {
103 throw new InvalidOperationException(
104 "A native solver parameter name is required.");
105 }
106
107 if (string.IsNullOrWhiteSpace(
108 Value))
109 {
110 throw new InvalidOperationException(
111 $"A value is required for native solver " +
112 $"parameter '{Name}'.");
113 }
114 }
115}
string Value
Gets or sets the native solver parameter value.
SolverNativeParameter()
Initializes an empty native solver parameter.
void EnsureValid()
Validates the native solver parameter.
SolverNativeParameter(string name, string value, SolverKind solverKind=SolverKind.Unknown)
Initializes a native solver parameter.
string Name
Gets or sets the native solver parameter name.
SolverKind SolverKind
Gets or sets the solver to which the parameter applies.