LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverDiscoveryOptions.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Xml.Serialization;
4
6
7/// <summary>
8/// Configures how solver adapter plugins and native solver
9/// installations are discovered on the current computer.
10/// </summary>
11[Serializable]
12[XmlType(TypeName = "solverDiscoveryOptions")]
13public sealed class SolverDiscoveryOptions
14{
15 private readonly List<string> _adapterSearchDirectories =
16 new();
17
18 private readonly List<string> _solverSearchDirectories =
19 new();
20
21 /// <summary>
22 /// Initializes solver-discovery options with recommended
23 /// defaults.
24 /// </summary>
26 {
28 true;
29
31 true;
32
34 "Plugins";
35
37 true;
38
40 true;
41
43 true;
44
46 false;
47
49 true;
50 }
51
52 /// <summary>
53 /// Gets or sets whether the application directory is
54 /// searched for solver adapter assemblies.
55 /// </summary>
56 [XmlAttribute("searchApplicationDirectory")]
58 {
59 get;
60 set;
61 }
62
63 /// <summary>
64 /// Gets or sets whether a plugin subdirectory of the
65 /// application directory is searched.
66 /// </summary>
67 [XmlAttribute("searchPluginSubdirectory")]
69 {
70 get;
71 set;
72 }
73
74 /// <summary>
75 /// Gets or sets the plugin subdirectory name.
76 /// </summary>
77 [XmlElement("pluginSubdirectoryName")]
79 {
80 get;
81 set;
82 }
83
84 /// <summary>
85 /// Gets or sets whether known solver environment variables
86 /// are inspected.
87 /// </summary>
88 [XmlAttribute("searchEnvironmentVariables")]
90 {
91 get;
92 set;
93 }
94
95 /// <summary>
96 /// Gets or sets whether directories listed in the operating
97 /// system PATH are inspected.
98 /// </summary>
99 [XmlAttribute("searchSystemPath")]
101 {
102 get;
103 set;
104 }
105
106 /// <summary>
107 /// Gets or sets whether common installation directories are
108 /// inspected.
109 /// </summary>
110 [XmlAttribute("searchCommonInstallationDirectories")]
112 {
113 get;
114 set;
115 }
116
117 /// <summary>
118 /// Gets or sets whether adapter search directories are
119 /// scanned recursively.
120 /// </summary>
121 [XmlAttribute("recursiveAdapterSearch")]
123 {
124 get;
125 set;
126 }
127
128 /// <summary>
129 /// Gets or sets whether solver-license availability is
130 /// checked during discovery.
131 /// </summary>
132 [XmlAttribute("validateLicenses")]
134 {
135 get;
136 set;
137 }
138
139 /// <summary>
140 /// Gets additional directories searched for solver adapter
141 /// assemblies.
142 /// </summary>
143 [XmlArray("adapterSearchDirectories")]
144 [XmlArrayItem("directory")]
145 public List<string> AdapterSearchDirectories =>
146 _adapterSearchDirectories;
147
148 /// <summary>
149 /// Gets additional directories searched for native solver
150 /// installations, libraries, and executables.
151 /// </summary>
152 [XmlArray("solverSearchDirectories")]
153 [XmlArrayItem("directory")]
154 public List<string> SolverSearchDirectories =>
155 _solverSearchDirectories;
156
157 /// <summary>
158 /// Validates the solver-discovery options.
159 /// </summary>
160 /// <exception cref="InvalidOperationException">
161 /// Thrown when one or more configured values are invalid.
162 /// </exception>
163 public void EnsureValid()
164 {
166 string.IsNullOrWhiteSpace(
168 {
169 throw new InvalidOperationException(
170 "A plugin subdirectory name is required when " +
171 "plugin-subdirectory discovery is enabled.");
172 }
173
174 ValidateDirectoryCollection(
175 _adapterSearchDirectories,
176 "adapter search");
177
178 ValidateDirectoryCollection(
179 _solverSearchDirectories,
180 "solver search");
181 }
182
183 private static void ValidateDirectoryCollection(
184 IEnumerable<string> directories,
185 string collectionName)
186 {
187 foreach (
188 string directory
189 in directories)
190 {
191 if (string.IsNullOrWhiteSpace(
192 directory))
193 {
194 throw new InvalidOperationException(
195 $"The {collectionName} directory collection " +
196 "cannot contain an empty value.");
197 }
198 }
199 }
200}
List< string > SolverSearchDirectories
Gets additional directories searched for native solver installations, libraries, and executables.
string PluginSubdirectoryName
Gets or sets the plugin subdirectory name.
bool SearchApplicationDirectory
Gets or sets whether the application directory is searched for solver adapter assemblies.
bool SearchEnvironmentVariables
Gets or sets whether known solver environment variables are inspected.
bool SearchCommonInstallationDirectories
Gets or sets whether common installation directories are inspected.
List< string > AdapterSearchDirectories
Gets additional directories searched for solver adapter assemblies.
SolverDiscoveryOptions()
Initializes solver-discovery options with recommended defaults.
bool RecursiveAdapterSearch
Gets or sets whether adapter search directories are scanned recursively.
bool SearchSystemPath
Gets or sets whether directories listed in the operating system PATH are inspected.
bool SearchPluginSubdirectory
Gets or sets whether a plugin subdirectory of the application directory is searched.
bool ValidateLicenses
Gets or sets whether solver-license availability is checked during discovery.
void EnsureValid()
Validates the solver-discovery options.