LotSizingDataModel.Solution 2.0.1
Solution objects for production, setup, inventory and related decisions.
Loading...
Searching...
No Matches
ProductionMicroPeriodDecision.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
3using LotSizingDataModel.Core.Common;
4using LotSizingDataModel.Core.DecisionModel.Scheduling;
5
7
8[Serializable]
9[XmlType(TypeName = "productionMicroPeriodDecision")]
10public sealed class ProductionMicroPeriodDecision : ModelObject
11{
12 private ProductionMicroPeriodReference _microPeriod = new();
13 private int _setupItemId;
14 private int _routingId;
15 private double _quantity;
16
20
22 ProductionMicroPeriodReference microPeriod,
23 int setupItemId,
24 int routingId = 0,
25 double quantity = 0.0)
26 {
27 MicroPeriod = microPeriod ??
28 throw new ArgumentNullException(nameof(microPeriod));
29 SetupItemId = setupItemId;
30 RoutingId = routingId;
31 Quantity = quantity;
32 }
33
34 [XmlElement("microPeriod")]
35 public ProductionMicroPeriodReference MicroPeriod
36 {
37 get => _microPeriod;
38 set
39 {
40 ArgumentNullException.ThrowIfNull(value);
41 SetProperty(ref _microPeriod, value);
42 }
43 }
44
45 [XmlAttribute("setupItemId")]
46 public int SetupItemId
47 {
48 get => _setupItemId;
49 set
50 {
51 if (value < 0)
52 throw new ArgumentOutOfRangeException(
53 nameof(value),
54 value,
55 "The setup item identifier cannot be negative.");
56
57 SetProperty(ref _setupItemId, value);
58 }
59 }
60
61 [XmlAttribute("routingId")]
62 public int RoutingId
63 {
64 get => _routingId;
65 set
66 {
67 if (value < 0)
68 throw new ArgumentOutOfRangeException(
69 nameof(value),
70 value,
71 "The routing identifier cannot be negative.");
72
73 SetProperty(ref _routingId, value);
74 }
75 }
76
77 [XmlAttribute("quantity")]
78 public double Quantity
79 {
80 get => _quantity;
81 set
82 {
83 if (!double.IsFinite(value) || value < 0.0)
84 throw new ArgumentOutOfRangeException(
85 nameof(value),
86 value,
87 "The micro-period production quantity must be finite and non-negative.");
88
89 SetProperty(ref _quantity, value);
90 }
91 }
92
93 [XmlIgnore]
94 public bool HasProduction => Quantity > 0.0;
95
96 [XmlIgnore]
97 public bool IsIdle => !HasProduction;
98
99 [XmlIgnore]
100 public bool IsInternallyValid =>
101 MicroPeriod.IsInternallyValid &&
102 SetupItemId >= 0 &&
103 RoutingId >= 0 &&
104 double.IsFinite(Quantity) &&
105 Quantity >= 0.0 &&
106 (!HasProduction ||
107 (SetupItemId > 0 && RoutingId > 0));
108
111 other is not null &&
112 MicroPeriod.RefersToSameMicroPeriod(other.MicroPeriod);
113}
ProductionMicroPeriodDecision(ProductionMicroPeriodReference microPeriod, int setupItemId, int routingId=0, double quantity=0.0)