LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverAvailabilityInfo.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Xml.Serialization;
4
6
7/// <summary>
8/// Describes the availability and detected installation details
9/// of a mathematical optimization solver.
10/// </summary>
11[Serializable]
12[XmlType(TypeName = "solverAvailabilityInfo")]
13public sealed class SolverAvailabilityInfo
14{
15 private readonly List<string> _diagnostics =
16 new();
17
18 private readonly List<string> _limitations =
19 new();
20
21 /// <summary>
22 /// Initializes an empty availability description.
23 /// </summary>
25 {
27 string.Empty;
28
30 string.Empty;
31
33 string.Empty;
34
36 string.Empty;
37
39 string.Empty;
40
42 string.Empty;
43 }
44
45 /// <summary>
46 /// Initializes an availability description for a solver.
47 /// </summary>
48 /// <param name="solverKind">
49 /// Solver kind.
50 /// </param>
51 /// <param name="status">
52 /// Availability status.
53 /// </param>
55 SolverKind solverKind,
57 : this()
58 {
60 solverKind;
61
62 Status =
63 status;
64 }
65
66 /// <summary>
67 /// Gets or sets the solver kind.
68 /// </summary>
69 [XmlAttribute("solverKind")]
71 {
72 get;
73 set;
74 }
75
76 /// <summary>
77 /// Gets or sets the detected availability status.
78 /// </summary>
79 [XmlAttribute("status")]
81 {
82 get;
83 set;
84 }
85
86 /// <summary>
87 /// Gets or sets the display name of the solver.
88 /// </summary>
89 [XmlElement("solverName")]
90 public string SolverName
91 {
92 get;
93 set;
94 }
95
96 /// <summary>
97 /// Gets or sets the detected solver version.
98 /// </summary>
99 [XmlElement("solverVersion")]
100 public string SolverVersion
101 {
102 get;
103 set;
104 }
105
106 /// <summary>
107 /// Gets or sets the detected installation directory.
108 /// </summary>
109 [XmlElement("installationPath")]
110 public string InstallationPath
111 {
112 get;
113 set;
114 }
115
116 /// <summary>
117 /// Gets or sets the path of the managed solver assembly,
118 /// when applicable.
119 /// </summary>
120 [XmlElement("managedAssemblyPath")]
122 {
123 get;
124 set;
125 }
126
127 /// <summary>
128 /// Gets or sets the path of the native solver library or
129 /// executable, when applicable.
130 /// </summary>
131 [XmlElement("nativeLibraryPath")]
132 public string NativeLibraryPath
133 {
134 get;
135 set;
136 }
137
138 /// <summary>
139 /// Gets or sets information about the detected solver
140 /// license.
141 /// </summary>
142 [XmlElement("licenseInformation")]
143 public string LicenseInformation
144 {
145 get;
146 set;
147 }
148
149 /// <summary>
150 /// Gets or sets a value indicating whether the solver can
151 /// currently be used.
152 /// </summary>
153 [XmlIgnore]
154 public bool IsUsable =>
155 Status is
157 SolverAvailabilityStatus.AvailableWithLimitations;
158
159 /// <summary>
160 /// Gets the diagnostic messages produced during solver
161 /// discovery and validation.
162 /// </summary>
163 [XmlArray("diagnostics")]
164 [XmlArrayItem("diagnostic")]
165 public List<string> Diagnostics =>
166 _diagnostics;
167
168 /// <summary>
169 /// Gets the functional limitations detected for the solver.
170 /// </summary>
171 [XmlArray("limitations")]
172 [XmlArrayItem("limitation")]
173 public List<string> Limitations =>
174 _limitations;
175
176 /// <summary>
177 /// Adds a diagnostic message.
178 /// </summary>
179 /// <param name="message">
180 /// Diagnostic message.
181 /// </param>
182 /// <exception cref="ArgumentException">
183 /// Thrown when <paramref name="message"/> is empty.
184 /// </exception>
185 public void AddDiagnostic(
186 string message)
187 {
188 if (string.IsNullOrWhiteSpace(
189 message))
190 {
191 throw new ArgumentException(
192 "A diagnostic message cannot be empty.",
193 nameof(message));
194 }
195
196 _diagnostics.Add(
197 message.Trim());
198 }
199
200 /// <summary>
201 /// Adds a functional limitation.
202 /// </summary>
203 /// <param name="limitation">
204 /// Limitation description.
205 /// </param>
206 /// <exception cref="ArgumentException">
207 /// Thrown when <paramref name="limitation"/> is empty.
208 /// </exception>
209 public void AddLimitation(
210 string limitation)
211 {
212 if (string.IsNullOrWhiteSpace(
213 limitation))
214 {
215 throw new ArgumentException(
216 "A limitation description cannot be empty.",
217 nameof(limitation));
218 }
219
220 _limitations.Add(
221 limitation.Trim());
222 }
223}
void AddDiagnostic(string message)
Adds a diagnostic message.
string NativeLibraryPath
Gets or sets the path of the native solver library or executable, when applicable.
string SolverVersion
Gets or sets the detected solver version.
string InstallationPath
Gets or sets the detected installation directory.
string LicenseInformation
Gets or sets information about the detected solver license.
List< string > Diagnostics
Gets the diagnostic messages produced during solver discovery and validation.
string SolverName
Gets or sets the display name of the solver.
void AddLimitation(string limitation)
Adds a functional limitation.
SolverAvailabilityInfo()
Initializes an empty availability description.
List< string > Limitations
Gets the functional limitations detected for the solver.
string ManagedAssemblyPath
Gets or sets the path of the managed solver assembly, when applicable.
SolverAvailabilityStatus Status
Gets or sets the detected availability status.
bool IsUsable
Gets or sets a value indicating whether the solver can currently be used.
SolverAvailabilityInfo(SolverKind solverKind, SolverAvailabilityStatus status)
Initializes an availability description for a solver.
SolverAvailabilityStatus
Describes the availability state of a solver adapter on the current computer.
@ Available
The solver is installed, loadable, licensed when required, and available for use.