LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SolverDiscoveryResult.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Xml.Serialization;
5
7
8/// <summary>
9/// Represents the complete result of solver and adapter
10/// discovery on the current computer.
11/// </summary>
12[Serializable]
13[XmlType(TypeName = "solverDiscoveryResult")]
14public sealed class SolverDiscoveryResult
15{
16 private readonly List<SolverDiscoveryCandidate>
17 _candidates =
18 new();
19
20 private readonly List<SolverAdapterDescriptor>
21 _adapterDescriptors =
22 new();
23
24 private readonly List<SolverAvailabilityInfo>
25 _availabilityInformation =
26 new();
27
28 private readonly List<string> _diagnostics =
29 new();
30
31 /// <summary>
32 /// Initializes an empty solver-discovery result.
33 /// </summary>
35 {
37 DateTime.UtcNow;
38 }
39
40 /// <summary>
41 /// Gets or sets the UTC date and time at which discovery
42 /// started.
43 /// </summary>
44 [XmlElement("startedAtUtc")]
45 public DateTime StartedAtUtc
46 {
47 get;
48 set;
49 }
50
51 /// <summary>
52 /// Gets or sets the UTC date and time at which discovery
53 /// completed.
54 /// </summary>
55 [XmlElement("completedAtUtc")]
56 public DateTime? CompletedAtUtc
57 {
58 get;
59 set;
60 }
61
62 /// <summary>
63 /// Gets or sets the elapsed discovery time in seconds.
64 /// </summary>
65 [XmlElement("elapsedSeconds")]
66 public double ElapsedSeconds
67 {
68 get;
69 set;
70 }
71
72 /// <summary>
73 /// Gets the discovered solver installation and adapter
74 /// location candidates.
75 /// </summary>
76 [XmlArray("candidates")]
77 [XmlArrayItem("candidate")]
78 public List<SolverDiscoveryCandidate> Candidates =>
79 _candidates;
80
81 /// <summary>
82 /// Gets the solver adapter descriptors discovered during
83 /// the scan.
84 /// </summary>
85 [XmlArray("adapterDescriptors")]
86 [XmlArrayItem("adapter")]
87 public List<SolverAdapterDescriptor> AdapterDescriptors =>
88 _adapterDescriptors;
89
90 /// <summary>
91 /// Gets the availability information reported for detected
92 /// solvers.
93 /// </summary>
94 [XmlArray("availabilityInformation")]
95 [XmlArrayItem("solver")]
96 public List<SolverAvailabilityInfo>
98 _availabilityInformation;
99
100 /// <summary>
101 /// Gets the diagnostics produced during discovery.
102 /// </summary>
103 [XmlArray("diagnostics")]
104 [XmlArrayItem("diagnostic")]
105 public List<string> Diagnostics =>
106 _diagnostics;
107
108 /// <summary>
109 /// Gets a value indicating whether at least one solver is
110 /// currently usable.
111 /// </summary>
112 [XmlIgnore]
113 public bool HasUsableSolver =>
114 _availabilityInformation.Exists(
115 availability =>
116 availability.IsUsable);
117
118 /// <summary>
119 /// Adds a diagnostic message.
120 /// </summary>
121 /// <param name="message">
122 /// Diagnostic message.
123 /// </param>
124 /// <exception cref="ArgumentException">
125 /// Thrown when <paramref name="message"/> is empty.
126 /// </exception>
127 public void AddDiagnostic(
128 string message)
129 {
130 if (string.IsNullOrWhiteSpace(
131 message))
132 {
133 throw new ArgumentException(
134 "A discovery diagnostic cannot be empty.",
135 nameof(message));
136 }
137
138 _diagnostics.Add(
139 message.Trim());
140 }
141
142 /// <summary>
143 /// Gets the availability information associated with a
144 /// solver kind.
145 /// </summary>
146 /// <param name="solverKind">
147 /// Solver kind to locate.
148 /// </param>
149 /// <returns>
150 /// Matching availability information, or
151 /// <see langword="null"/> when none is available.
152 /// </returns>
154 SolverKind solverKind)
155 {
156 return _availabilityInformation.Find(
157 availability =>
158 availability.SolverKind ==
159 solverKind);
160 }
161}
Describes the availability and detected installation details of a mathematical optimization solver.
DateTime? CompletedAtUtc
Gets or sets the UTC date and time at which discovery completed.
List< SolverAvailabilityInfo > AvailabilityInformation
Gets the availability information reported for detected solvers.
List< SolverAdapterDescriptor > AdapterDescriptors
Gets the solver adapter descriptors discovered during the scan.
List< string > Diagnostics
Gets the diagnostics produced during discovery.
bool HasUsableSolver
Gets a value indicating whether at least one solver is currently usable.
void AddDiagnostic(string message)
Adds a diagnostic message.
DateTime StartedAtUtc
Gets or sets the UTC date and time at which discovery started.
double ElapsedSeconds
Gets or sets the elapsed discovery time in seconds.
SolverDiscoveryResult()
Initializes an empty solver-discovery result.
SolverAvailabilityInfo? FindAvailability(SolverKind solverKind)
Gets the availability information associated with a solver kind.
List< SolverDiscoveryCandidate > Candidates
Gets the discovered solver installation and adapter location candidates.
SolverKind
Identifies a supported mathematical optimization solver.
Definition SolverKind.cs:12