LotSizingDataModel.Instance 2.0.1
Lot-sizing instance representation, descriptors and problem characterization.
Loading...
Searching...
No Matches
WolseySingleItemClassification.cs
Go to the documentation of this file.
2
3/// <summary>
4/// Lossless typed representation of Wolsey's PROB-CAP-VAR single-item
5/// classification.
6/// </summary>
8{
9 private readonly IReadOnlyCollection<WolseyVariant> _variants;
10
13 WolseyCapacityRegime capacity,
14 IEnumerable<WolseyVariant>? variants = null)
15 {
16 Problem = problem;
17 Capacity = capacity;
18
19 _variants =
20 (variants ?? Array.Empty<WolseyVariant>())
21 .Distinct()
22 .OrderBy(variant => (int)variant)
23 .ToArray();
24 }
25
28 public IReadOnlyCollection<WolseyVariant> Variants => _variants;
29
30 /// <summary>
31 /// Renders a stable LotSizingDataModel canonical transcription of the
32 /// historical PROB-CAP-VAR code.
33 /// </summary>
34 /// <remarks>
35 /// Empty VAR is omitted, as in Wolsey's WW-U example.
36 /// Multiple variants are rendered as a set using comma separators.
37 /// </remarks>
38 public string HistoricalCode
39 {
40 get
41 {
42 string core =
43 $"{Problem}-{Capacity}";
44
45 if (_variants.Count == 0)
46 {
47 return core;
48 }
49
50 return
51 core +
52 "-{" +
53 string.Join(
54 ",",
55 _variants.Select(RenderVariant)) +
56 "}";
57 }
58 }
59
60 public bool HasVariant(WolseyVariant variant) =>
61 _variants.Contains(variant);
62
63 private static string RenderVariant(
64 WolseyVariant variant)
65 {
66 return variant switch
67 {
68 WolseyVariant.STConstant => "ST(C)",
69 WolseyVariant.LBConstant => "LB(C)",
70 _ => variant.ToString()
71 };
72 }
73
74 public override string ToString() =>
76}
WolseySingleItemClassification(WolseyProblemVersion problem, WolseyCapacityRegime capacity, IEnumerable< WolseyVariant >? variants=null)
string HistoricalCode
Renders a stable LotSizingDataModel canonical transcription of the historical PROB-CAP-VAR code.
WolseyCapacityRegime
Second CAP field of Wolsey's 2002 single-item classification.
WolseyVariant
Third VAR field extensions of Wolsey's 2002 single-item classification.
@ STConstant
Constant start-up times, Wolsey ST(C).
@ LBConstant
Constant minimum production levels, Wolsey LB(C).
WolseyProblemVersion
First PROB field of Wolsey's 2002 single-item classification.