LotSizingDataModel.Core 2.1.0
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
SupplyChainValidator.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
6
8
9/// <summary>
10/// Validates the structural, referential and decision-model
11/// consistency of a complete supply chain.
12/// </summary>
13public sealed class SupplyChainValidator
14{
15 /// <summary>
16 /// Indicates the severity of a supply-chain validation issue.
17 /// </summary>
19 {
20 /// <summary>
21 /// Indicates a non-blocking validation warning.
22 /// </summary>
24
25 /// <summary>
26 /// Indicates a validation error that makes the model invalid.
27 /// </summary>
29 }
30
31 /// <summary>
32 /// Represents one issue detected during validation.
33 /// </summary>
34 public sealed class ValidationIssue
35 {
36 /// <summary>
37 /// Initializes a new validation issue.
38 /// </summary>
39 /// <param name="severity">
40 /// Severity of the detected issue.
41 /// </param>
42 /// <param name="code">
43 /// Stable technical code identifying the validation rule.
44 /// </param>
45 /// <param name="path">
46 /// Logical path of the object or property concerned
47 /// by the issue.
48 /// </param>
49 /// <param name="message">
50 /// Human-readable description of the issue.
51 /// </param>
53 ValidationSeverity severity,
54 string code,
55 string path,
56 string message)
57 {
58 Severity = severity;
59 Code = code ??
60 throw new ArgumentNullException(nameof(code));
61 Path = path ??
62 throw new ArgumentNullException(nameof(path));
63 Message = message ??
64 throw new ArgumentNullException(nameof(message));
65 }
66
67 /// <summary>
68 /// Gets the severity of the validation issue.
69 /// </summary>
71
72 /// <summary>
73 /// Gets the stable technical code identifying
74 /// the validation rule.
75 /// </summary>
76 public string Code { get; }
77
78 /// <summary>
79 /// Gets the logical path of the model element concerned
80 /// by the validation issue.
81 /// </summary>
82 public string Path { get; }
83
84 /// <summary>
85 /// Gets the human-readable description of the issue.
86 /// </summary>
87 public string Message { get; }
88
89 /// <inheritdoc/>
90 public override string ToString()
91 {
92 return
93 $"[{Severity}] {Code} at {Path}: {Message}";
94 }
95 }
96
97 /// <summary>
98 /// Validates a complete supply-chain model.
99 /// </summary>
100 /// <param name="supplyChain">
101 /// Supply chain to validate.
102 /// </param>
103 /// <returns>
104 /// All errors and warnings detected in the model.
105 /// </returns>
106 public IReadOnlyList<ValidationIssue> Validate(
107 SupplyChain supplyChain)
108 {
109 ArgumentNullException.ThrowIfNull(supplyChain);
110
111 var issues = new List<ValidationIssue>();
112
113 ValidateRoot(supplyChain, issues);
114 ValidateLogicalSubsystem(supplyChain, issues);
115 ValidatePhysicalSubsystem(supplyChain, issues);
116 ValidateProductionRoutings(supplyChain, issues);
117 ValidateProductionCharacteristics(supplyChain, issues);
119 supplyChain,
120 issues);
121 ValidateInventories(supplyChain, issues);
122 ValidateTransportCharacteristics(supplyChain, issues);
123 ValidateDemands(supplyChain, issues);
124 ValidateDistributionCenterSourcings(
125 supplyChain,
126 issues);
127 ValidateSupplierDeliveries(supplyChain, issues);
128
129 return issues.AsReadOnly();
130 }
131
132 /// <summary>
133 /// Determines whether a supply chain contains no
134 /// validation error.
135 ///
136 /// Warnings do not make the model invalid.
137 /// </summary>
138 public bool IsValid(SupplyChain supplyChain)
139 {
140 return Validate(supplyChain).All(
141 issue =>
142 issue.Severity !=
143 ValidationSeverity.Error);
144 }
145
146 /// <summary>
147 /// Validates the model and throws an exception when at least
148 /// one validation error is detected.
149 /// </summary>
150 public void ThrowIfInvalid(SupplyChain supplyChain)
151 {
152 // Collect only errors; warnings do not make the model invalid.
153 ValidationIssue[] errors =
154 Validate(supplyChain)
155 .Where(
156 issue =>
157 issue.Severity ==
158 ValidationSeverity.Error)
159 .ToArray();
160
161 if (errors.Length == 0)
162 {
163 return;
164 }
165
166 string message = string.Join(
167 Environment.NewLine,
168 errors.Select(error => error.ToString()));
169
170 throw new InvalidOperationException(
171 "The supply-chain model is invalid." +
172 Environment.NewLine +
173 message);
174 }
175
176 private static void ValidateRoot(
177 SupplyChain supplyChain,
178 ICollection<ValidationIssue> issues)
179 {
180 if (supplyChain.PlanningHorizon <= 0)
181 {
182 AddError(
183 issues,
184 "SC001",
185 "supplyChain.planningHorizon",
186 "The planning horizon must be strictly positive.");
187 }
188
189 if (supplyChain.Items.Count == 0)
190 {
191 AddError(
192 issues,
193 "SC002",
194 "supplyChain.items",
195 "The supply chain must contain at least one item.");
196 }
197
198 if (!supplyChain.HasConsistentPlanningHorizon)
199 {
200 AddError(
201 issues,
202 "SC003",
203 "supplyChain",
204 "At least one period-dependent object does not " +
205 "use the global planning horizon.");
206 }
207 }
208
209 private static void ValidateLogicalSubsystem(
210 SupplyChain supplyChain,
211 ICollection<ValidationIssue> issues)
212 {
213 ValidateIdentifiedCollection(
214 supplyChain.Items,
215 item => item.Id,
216 item => item.Name,
217 "supplyChain.items",
218 "item",
219 issues);
220
221 var requirementKeys =
222 new HashSet<string>(StringComparer.Ordinal);
223
224 for (int index = 0;
225 index < supplyChain.ComponentRequirements.Count;
226 index++)
227 {
228 var requirement =
229 supplyChain.ComponentRequirements[index];
230
231 string path =
232 $"supplyChain.componentRequirements[{index}]";
233
234 string key =
235 $"{requirement.ParentItemId}:" +
236 $"{requirement.ComponentItemId}";
237
238 if (!requirementKeys.Add(key))
239 {
240 AddError(
241 issues,
242 "BOM001",
243 path,
244 "The same parent-item/component-item " +
245 "requirement is defined more than once.");
246 }
247
248 if (!ItemExists(
249 supplyChain,
250 requirement.ParentItemId))
251 {
252 AddError(
253 issues,
254 "BOM002",
255 path + ".parentItemId",
256 $"Item {requirement.ParentItemId} does not exist.");
257 }
258
259 if (!ItemExists(
260 supplyChain,
261 requirement.ComponentItemId))
262 {
263 AddError(
264 issues,
265 "BOM003",
266 path + ".componentItemId",
267 $"Item {requirement.ComponentItemId} does not exist.");
268 }
269
270 if (requirement.ParentItemId ==
271 requirement.ComponentItemId)
272 {
273 AddError(
274 issues,
275 "BOM004",
276 path,
277 "An item cannot be its own component.");
278 }
279
280 if (requirement.Quantity <= 0)
281 {
282 AddError(
283 issues,
284 "BOM005",
285 path + ".quantity",
286 "A component quantity must be strictly positive.");
287 }
288 }
289
290 ValidateBillOfMaterialsCycles(
291 supplyChain,
292 issues);
293 }
294
295 private static void ValidateBillOfMaterialsCycles(
296 SupplyChain supplyChain,
297 ICollection<ValidationIssue> issues)
298 {
299 Dictionary<int, List<int>> graph =
300 supplyChain.ComponentRequirements
301 .GroupBy(
302 requirement =>
303 requirement.ParentItemId)
304 .ToDictionary(
305 group => group.Key,
306 group => group
307 .Select(
308 requirement =>
309 requirement.ComponentItemId)
310 .ToList());
311
312 var states = new Dictionary<int, int>();
313
314 foreach (int itemId in supplyChain.Items.Select(
315 item => item.Id))
316 {
317 if (ContainsCycle(
318 itemId,
319 graph,
320 states))
321 {
322 AddError(
323 issues,
324 "BOM006",
325 "supplyChain.componentRequirements",
326 "The bill of materials contains at least " +
327 "one circular dependency.");
328
329 return;
330 }
331 }
332 }
333
334 private static bool ContainsCycle(
335 int itemId,
336 IReadOnlyDictionary<int, List<int>> graph,
337 IDictionary<int, int> states)
338 {
339 if (states.TryGetValue(itemId, out int state))
340 {
341 return state == 1;
342 }
343
344 states[itemId] = 1;
345
346 if (graph.TryGetValue(
347 itemId,
348 out List<int>? components))
349 {
350 foreach (int componentId in components)
351 {
352 if (ContainsCycle(
353 componentId,
354 graph,
355 states))
356 {
357 return true;
358 }
359 }
360 }
361
362 states[itemId] = 2;
363
364 return false;
365 }
366
367 private static void ValidatePhysicalSubsystem(
368 SupplyChain supplyChain,
369 ICollection<ValidationIssue> issues)
370 {
371 ValidateIdentifiedCollection(
372 supplyChain.Plants,
373 plant => plant.Id,
374 plant => plant.Name,
375 "supplyChain.plants",
376 "plant",
377 issues);
378
379 ValidateIdentifiedCollection(
380 supplyChain.StandaloneWarehouses,
381 warehouse => warehouse.Id,
382 warehouse => warehouse.Name,
383 "supplyChain.standaloneWarehouses",
384 "standalone warehouse",
385 issues);
386
387 ValidateIdentifiedCollection(
388 supplyChain.Suppliers,
389 supplier => supplier.Id,
390 supplier => supplier.Name,
391 "supplyChain.suppliers",
392 "supplier",
393 issues);
394
395 ValidateIdentifiedCollection(
396 supplyChain.DistributionCenters,
397 center => center.Id,
398 center => center.Name,
399 "supplyChain.distributionCenters",
400 "distribution center",
401 issues);
402
403 ValidateIdentifiedCollection(
404 supplyChain.TransportResources,
405 resource => resource.Id,
406 resource => resource.Name,
407 "supplyChain.transportResources",
408 "transport resource",
409 issues);
410
411 foreach (Plant plant in supplyChain.Plants)
412 {
413 string plantPath =
414 $"supplyChain.plants[id={plant.Id}]";
415
416 if (plant.WorkCenters.Count == 0)
417 {
418 AddError(
419 issues,
420 "PHY001",
421 plantPath + ".workCenters",
422 "A plant must contain at least one work center.");
423 }
424
425 ValidateIdentifiedCollection(
426 plant.WorkCenters,
427 workCenter => workCenter.Id,
428 workCenter => workCenter.Name,
429 plantPath + ".workCenters",
430 "work center",
431 issues);
432
434 {
435 var seenItemIds = new HashSet<int>();
436 for (int index = 0; index < plant.ManufacturedItemIds.Count; index++)
437 {
438 int itemId = plant.ManufacturedItemIds[index];
439 string path = $"{plantPath}.manufacturedItemIds[{index}]";
440 if (itemId <= 0 || !ItemExists(supplyChain, itemId))
441 {
442 AddError(issues, "PHY002", path,
443 $"Manufactured item {itemId} must identify an existing item.");
444 }
445 else if (!seenItemIds.Add(itemId))
446 {
447 AddError(issues, "PHY003", path,
448 $"Manufactured item {itemId} is declared more than once.");
449 }
450 }
451 }
452
453 ValidateWarehouseDecisionModel(
454 plant.Warehouse,
455 plantPath + ".warehouse",
456 supplyChain.PlanningHorizon,
457 issues);
458
459 foreach (WorkCenter workCenter
460 in plant.WorkCenters)
461 {
462 ValidateWorkCenterDecisionModel(
463 workCenter,
464 plantPath +
465 $".workCenters[id={workCenter.Id}]",
466 supplyChain.PlanningHorizon,
467 issues);
468 }
469 }
470
471 foreach (StandaloneWarehouse warehouse
472 in supplyChain.StandaloneWarehouses)
473 {
474 ValidateWarehouseDecisionModel(
475 warehouse,
476 "supplyChain.standaloneWarehouses" +
477 $"[id={warehouse.Id}]",
478 supplyChain.PlanningHorizon,
479 issues);
480 }
481
482 foreach (TransportResource resource
483 in supplyChain.TransportResources)
484 {
485 string path =
486 "supplyChain.transportResources" +
487 $"[id={resource.Id}]";
488
489 ValidatePhysicalFleet(supplyChain, resource.PhysicalFleet, path + ".physicalFleet", issues);
490 ValidateTransportResourceDecisionModel(
491 resource,
492 path,
493 supplyChain.PlanningHorizon,
494 issues);
495
496 }
497 var laneIds = new HashSet<int>();
498 var laneKeys = new HashSet<string>(StringComparer.Ordinal);
499 foreach (TransportLane lane in supplyChain.TransportLanes)
500 {
501 string path = $"supplyChain.transportLanes[id={lane.Id}]";
502 if (lane.Id < 0 || !laneIds.Add(lane.Id)) AddError(issues, "TRN005", path, "Invalid or duplicate lane identifier.");
503 ValidateWarehouseReference(supplyChain, lane.Origin, path + ".origin", issues);
504 ValidateWarehouseReference(supplyChain, lane.Destination, path + ".destination", issues);
505 if (SameWarehouse(lane.Origin, lane.Destination)) AddError(issues, "TRN002", path, "The origin and destination warehouses must be different.");
506 if (!laneKeys.Add(WarehouseKey(lane.Origin) + "->" + WarehouseKey(lane.Destination)))
507 AddError(issues, "TRN004", path, "Duplicate directed transport lane.");
508 }
509 var assignments = new HashSet<(int, int)>();
510 foreach (TransportAssignment assignment in supplyChain.TransportAssignments)
511 {
512 string path = $"supplyChain.transportAssignments[lane={assignment.LaneId},resource={assignment.TransportResourceId}]";
513 if (!laneIds.Contains(assignment.LaneId) || !supplyChain.TransportResources.Any(r => r.Id == assignment.TransportResourceId))
514 AddError(issues, "TRN006", path, "An assignment references a missing lane or resource.");
515 if (!assignments.Add((assignment.LaneId, assignment.TransportResourceId)))
516 AddError(issues, "TRN007", path, "Duplicate lane-resource assignment.");
517 if (assignment.LeadTime < 0) AddError(issues, "TRN003", path, "A transport lead time cannot be negative.");
518 }
519 if (supplyChain.TransportFormatVersion != 2)
520 AddError(issues, "TRN008", "supplyChain.transportFormatVersion", "Unsupported transport format version.");
521 }
522
523 private static void ValidatePhysicalFleet(SupplyChain chain, PhysicalTransportFleet? fleet, string path, ICollection<ValidationIssue> issues)
524 {
525 if (fleet is null)
526 return;
527
528 if (fleet.VehicleCount <= 0 || fleet.CapacityPerVehicle <= 0)
529 AddError(issues, "FLEET001", path, "Le nombre de véhicules et la capacité unitaire doivent être positifs.");
530
531 var sites = new HashSet<string>(StringComparer.Ordinal);
532 long total = 0;
533 foreach (var row in fleet.InitialAllocation)
534 {
535 if (row is null || row.Count <= 0 || ResolveWarehouse(chain, row.Warehouse) is null ||
536 !sites.Add(WarehouseKey(row.Warehouse)))
537 AddError(issues, "FLEET002", path, "Utilisez des entrepôts existants et distincts pour la répartition initiale.");
538 total += row?.Count ?? 0;
539 }
540 if (total != fleet.VehicleCount)
541 AddError(issues, "FLEET003", path, "Le total de la répartition initiale doit égaler la taille de la flotte.");
542
543 var movements = new HashSet<(string, string)>();
544 foreach (var row in fleet.EmptyMovements)
545 {
546 if (row is null || row.Duration <= 0 || row.CostPerVehicle < 0 || SameWarehouse(row.Origin, row.Destination) ||
547 ResolveWarehouse(chain, row.Origin) is null || ResolveWarehouse(chain, row.Destination) is null ||
548 !movements.Add((WarehouseKey(row.Origin), WarehouseKey(row.Destination))))
549 AddError(issues, "FLEET004", path, "Chaque déplacement à vide doit relier deux entrepôts distincts, avec une durée positive et sans doublon.");
550 }
551 }
552
553 /// <summary>Advisory transport readiness diagnostics, independent of structural validity.</summary>
554 public IReadOnlyList<ValidationIssue> ValidateTransportReadiness(SupplyChain supplyChain)
555 {
556 ArgumentNullException.ThrowIfNull(supplyChain);
557 var issues = new List<ValidationIssue>();
558 foreach (var lane in supplyChain.TransportLanes.Where(l => !supplyChain.TransportAssignments.Any(a => a.LaneId == l.Id)))
559 issues.Add(new ValidationIssue(ValidationSeverity.Warning, "TRNR001", $"transportLanes[id={lane.Id}]", "No resource is assigned to this lane."));
560 foreach (var resource in supplyChain.TransportResources.Where(r => !supplyChain.TransportAssignments.Any(a => a.TransportResourceId == r.Id)))
561 issues.Add(new ValidationIssue(ValidationSeverity.Warning, "TRNR002", $"transportResources[id={resource.Id}]", "This resource serves no lane."));
562 return issues;
563 }
564
565 private static void ValidateProductionRoutings(
566 SupplyChain supplyChain,
567 ICollection<ValidationIssue> issues)
568 {
569 var routingIds = new HashSet<int>();
570
571 for (int index = 0;
572 index < supplyChain.ProductionRoutings.Count;
573 index++)
574 {
575 ProductionRouting routing =
576 supplyChain.ProductionRoutings[index];
577
578 string path =
579 $"supplyChain.productionRoutings[{index}]";
580
581 if (routing.Id <= 0)
582 {
583 AddError(
584 issues,
585 "ROU001",
586 path + ".id",
587 "A production-routing identifier must be " +
588 "strictly positive.");
589 }
590
591 if (!routingIds.Add(routing.Id))
592 {
593 AddError(
594 issues,
595 "ROU002",
596 path + ".id",
597 $"Production-routing identifier {routing.Id} " +
598 "is duplicated.");
599 }
600
601 if (!ItemExists(
602 supplyChain,
603 routing.ItemId))
604 {
605 AddError(
606 issues,
607 "ROU003",
608 path + ".itemId",
609 $"Item {routing.ItemId} does not exist.");
610 }
611
612 Plant? plant =
613 FindPlant(
614 supplyChain,
615 routing.PlantId);
616
617 if (plant is null)
618 {
619 AddError(
620 issues,
621 "ROU004",
622 path + ".plantId",
623 $"Plant {routing.PlantId} does not exist.");
624 }
625
626 if (plant is not null && plant.ManufacturedItemIdsSpecified &&
627 !plant.ManufacturedItemIds.Contains(routing.ItemId))
628 {
629 AddError(issues, "ROU011", path + ".itemId",
630 $"Item {routing.ItemId} is not declared as manufactured by plant {routing.PlantId}.");
631 }
632
633 if (routing.LeadTime < 0)
634 {
635 AddError(
636 issues,
637 "ROU005",
638 path + ".leadTime",
639 "A production lead time cannot be negative.");
640 }
641
642 if (routing.WorkCenters.Count == 0)
643 {
644 AddError(
645 issues,
646 "ROU006",
647 path + ".workCenters",
648 "A production routing must use at least " +
649 "one work center.");
650 }
651
652 var workCenterKeys =
653 new HashSet<string>(StringComparer.Ordinal);
654
655 foreach (WorkCenterReference reference
656 in routing.WorkCenters)
657 {
658 string key =
659 WorkCenterKey(reference);
660
661 if (!workCenterKeys.Add(key))
662 {
663 AddError(
664 issues,
665 "ROU007",
666 path + ".workCenters",
667 "The same work center is referenced more " +
668 "than once by the routing.");
669 }
670
671 if (reference.PlantId != routing.PlantId)
672 {
673 AddError(
674 issues,
675 "ROU008",
676 path + ".workCenters",
677 "Every referenced work center must belong " +
678 "to the routing plant.");
679 }
680
681 if (ResolveWorkCenter(
682 supplyChain,
683 reference) is null)
684 {
685 AddError(
686 issues,
687 "ROU009",
688 path + ".workCenters",
689 $"Work center {key} does not exist.");
690 }
691
692 bool characteristicExists =
693 supplyChain.ProductionCharacteristics.Any(
694 characteristic =>
695 characteristic.ItemId ==
696 routing.ItemId &&
697 SameWorkCenter(
698 characteristic.WorkCenter,
699 reference));
700
701 if (!characteristicExists)
702 {
703 AddWarning(
704 issues,
705 "ROU010",
706 path + ".workCenters",
707 $"No production characteristic is defined " +
708 $"for item {routing.ItemId} and work " +
709 $"center {key}.");
710 }
711 }
712
713 ValidatePlanningHorizon(
714 path,
716 routing.PlanningHorizon,
718 supplyChain.PlanningHorizon,
719 issues);
720 }
721 }
722
723 private static void ValidateProductionCharacteristics(
724 SupplyChain supplyChain,
725 ICollection<ValidationIssue> issues)
726 {
727 var keys =
728 new HashSet<string>(StringComparer.Ordinal);
729
730 for (int index = 0;
731 index <
732 supplyChain.ProductionCharacteristics.Count;
733 index++)
734 {
735 ProductionCharacteristic characteristic =
736 supplyChain.ProductionCharacteristics[index];
737
738 string path =
739 "supplyChain.productionCharacteristics" +
740 $"[{index}]";
741
742 if (!ItemExists(
743 supplyChain,
744 characteristic.ItemId))
745 {
746 AddError(
747 issues,
748 "PRD001",
749 path + ".itemId",
750 $"Item {characteristic.ItemId} does not exist.");
751 }
752
753 if (characteristic.WorkCenter is null)
754 {
755 AddError(
756 issues,
757 "PRD002",
758 path + ".workCenter",
759 "A production characteristic must reference " +
760 "a work center.");
761
762 continue;
763 }
764
765 string key =
766 $"{characteristic.ItemId}:" +
767 WorkCenterKey(characteristic.WorkCenter);
768
769 if (!keys.Add(key))
770 {
771 AddError(
772 issues,
773 "PRD003",
774 path,
775 "A production characteristic is duplicated " +
776 "for this item and work center.");
777 }
778
779 WorkCenter? workCenter =
780 ResolveWorkCenter(
781 supplyChain,
782 characteristic.WorkCenter);
783
784 if (workCenter is null)
785 {
786 AddError(
787 issues,
788 "PRD004",
789 path + ".workCenter",
790 "The referenced work center does not exist.");
791 }
792 ValidatePlanningHorizon(
793 path,
794 characteristic.HasDecisionParameters,
795 characteristic.PlanningHorizon,
796 characteristic.HasConsistentPlanningHorizon,
797 supplyChain.PlanningHorizon,
798 issues);
799 }
800 }
801
802 private static void ValidateInventories(
803 SupplyChain supplyChain,
804 ICollection<ValidationIssue> issues)
805 {
806 var keys =
807 new HashSet<string>(StringComparer.Ordinal);
808
809 for (int index = 0;
810 index < supplyChain.Inventories.Count;
811 index++)
812 {
813 Inventory inventory =
814 supplyChain.Inventories[index];
815
816 string path =
817 $"supplyChain.inventories[{index}]";
818
819 if (!ItemExists(
820 supplyChain,
821 inventory.ItemId))
822 {
823 AddError(
824 issues,
825 "INV001",
826 path + ".itemId",
827 $"Item {inventory.ItemId} does not exist.");
828 }
829
830 ValidateWarehouseReference(
831 supplyChain,
832 inventory.Warehouse,
833 path + ".warehouse",
834 issues);
835
836 string key =
837 $"{inventory.ItemId}:" +
838 WarehouseKey(inventory.Warehouse);
839
840 if (!keys.Add(key))
841 {
842 AddError(
843 issues,
844 "INV002",
845 path,
846 "An inventory is duplicated for this item " +
847 "and warehouse.");
848 }
849
850 if (!double.IsFinite(inventory.InitialInventory) ||
851 inventory.InitialInventory < 0.0)
852 {
853 AddError(
854 issues,
855 "INV003",
856 path + ".initialInventory",
857 "Initial inventory must be finite and " +
858 "non-negative.");
859 }
860
861 if (inventory.InventoryBalanceRule is null)
862 {
863 AddError(
864 issues,
865 "INV004",
866 path + ".inventoryBalanceRule",
867 "Every inventory must contain an inventory-" +
868 "balance rule.");
869 }
870
871 if (!inventory.HasValidDecisionConfiguration)
872 {
873 AddError(
874 issues,
875 "INV005",
876 path,
877 "The dependencies between the inventory " +
878 "constraints and costs are invalid.");
879 }
880
881 Warehouse? warehouse =
882 ResolveWarehouse(
883 supplyChain,
884 inventory.Warehouse);
885
886 bool usesCapacity =
887 inventory.UnitCapacityConsumption is not null ||
888 inventory.SetupTime is not null;
889
890 bool hasApplicableCapacity =
891 inventory.CapacityConstraint is not null ||
892 warehouse?.CapacityConstraint is not null;
893
894 if (usesCapacity && !hasApplicableCapacity)
895 {
896 AddError(
897 issues,
898 "INV006",
899 path,
900 "Unit-capacity consumption or setup time is " +
901 "defined, but neither the inventory nor its " +
902 "warehouse has a capacity constraint.");
903 }
904
905 ValidatePlanningHorizon(
906 path,
907 inventory.HasDecisionParameters,
908 inventory.PlanningHorizon,
910 supplyChain.PlanningHorizon,
911 issues);
912 }
913 }
914
915 private static void ValidateTransportCharacteristics(
916 SupplyChain supplyChain,
917 ICollection<ValidationIssue> issues)
918 {
919 var keys =
920 new HashSet<string>(StringComparer.Ordinal);
921
922 for (int index = 0;
923 index <
924 supplyChain.TransportCharacteristics.Count;
925 index++)
926 {
927 TransportCharacteristic characteristic =
928 supplyChain.TransportCharacteristics[index];
929
930 string path =
931 "supplyChain.transportCharacteristics" +
932 $"[{index}]";
933
934 if (!ItemExists(
935 supplyChain,
936 characteristic.ItemId))
937 {
938 AddError(
939 issues,
940 "TCH001",
941 path + ".itemId",
942 $"Item {characteristic.ItemId} does not exist.");
943 }
944
945 TransportResource? resource =
946 FindTransportResource(
947 supplyChain,
948 characteristic.TransportResourceId);
949
950 if (resource is null)
951 {
952 AddError(
953 issues,
954 "TCH002",
955 path + ".transportResourceId",
956 "The referenced transport resource does not exist.");
957 }
958
959 string key =
960 $"{characteristic.ItemId}:" +
961 $"{characteristic.TransportResourceId}";
962
963 if (!keys.Add(key))
964 {
965 AddError(
966 issues,
967 "TCH003",
968 path,
969 "A transport characteristic is duplicated " +
970 "for this item and transport resource.");
971 }
972
973 if (characteristic.AdditionalCapacity is not null &&
974 characteristic.CapacityConstraint is null)
975 {
976 AddError(
977 issues,
978 "TCH004",
979 path + ".additionalCapacity",
980 "Item-specific additional capacity requires " +
981 "an item-specific capacity constraint.");
982 }
983
984 if (characteristic.AdditionalCapacityCost is not null &&
985 characteristic.AdditionalCapacity is null)
986 {
987 AddError(
988 issues,
989 "TCH005",
990 path + ".additionalCapacityCost",
991 "An additional-capacity cost requires an " +
992 "additional-capacity constraint.");
993 }
994
995 bool usesCapacity =
996 characteristic.UnitCapacityConsumption is not null ||
997 characteristic.SetupTime is not null;
998
999 bool hasApplicableCapacity =
1000 characteristic.CapacityConstraint is not null ||
1001 resource?.CapacityConstraint is not null ||
1002 (resource?.PhysicalFleet is not null && characteristic.SetupTime is null);
1003
1004 if (resource?.PhysicalFleet is not null &&
1005 characteristic.UnitCapacityConsumption is { } consumption &&
1006 consumption.Values.Any(value => value <= 0.0))
1007 {
1008 AddError(
1009 issues,
1010 "TCH007",
1011 path + ".unitCapacityConsumption",
1012 "A physical fleet requires strictly positive unit-capacity consumption.");
1013 }
1014
1015 if (usesCapacity && !hasApplicableCapacity)
1016 {
1017 AddError(
1018 issues,
1019 "TCH006",
1020 path,
1021 "Unit-capacity consumption or setup time is " +
1022 "defined, but neither the characteristic nor " +
1023 "the transport resource has a capacity constraint.");
1024 }
1025
1026 ValidatePlanningHorizon(
1027 path,
1028 characteristic.HasDecisionParameters,
1029 characteristic.PlanningHorizon,
1030 characteristic.HasConsistentPlanningHorizon,
1031 supplyChain.PlanningHorizon,
1032 issues);
1033 }
1034 }
1035
1036 private static void ValidateDemands(
1037 SupplyChain supplyChain,
1038 ICollection<ValidationIssue> issues)
1039 {
1040 var keys =
1041 new HashSet<string>(StringComparer.Ordinal);
1042
1043 for (int index = 0;
1044 index < supplyChain.Demands.Count;
1045 index++)
1046 {
1047 Demand demand =
1048 supplyChain.Demands[index];
1049
1050 string path =
1051 $"supplyChain.demands[{index}]";
1052
1053 if (!ItemExists(
1054 supplyChain,
1055 demand.ItemId))
1056 {
1057 AddError(
1058 issues,
1059 "DEM001",
1060 path + ".itemId",
1061 $"Item {demand.ItemId} does not exist.");
1062 }
1063
1064 if (!DistributionCenterExists(
1065 supplyChain,
1066 demand.DistributionCenterId))
1067 {
1068 AddError(
1069 issues,
1070 "DEM002",
1071 path + ".distributionCenterId",
1072 "The referenced distribution center does not exist.");
1073 }
1074
1075 string key =
1076 $"{demand.DistributionCenterId}:" +
1077 $"{demand.ItemId}";
1078
1079 if (!keys.Add(key))
1080 {
1081 AddError(
1082 issues,
1083 "DEM003",
1084 path,
1085 "A demand is duplicated for this distribution " +
1086 "center and item.");
1087 }
1088
1089 if (!demand.HasValidQuantities)
1090 {
1091 AddError(
1092 issues,
1093 "DEM004",
1094 path + ".quantities",
1095 "Demand quantities must be finite and non-negative.");
1096 }
1097
1098 if (demand.PlanningHorizon !=
1099 supplyChain.PlanningHorizon)
1100 {
1101 AddError(
1102 issues,
1103 "DEM005",
1104 path + ".quantities",
1105 "The demand time series does not use the global " +
1106 "planning horizon.");
1107 }
1108 }
1109 }
1110
1111 private static void ValidateDistributionCenterSourcings(
1112 SupplyChain supplyChain,
1113 ICollection<ValidationIssue> issues)
1114 {
1115 var keys =
1116 new HashSet<string>(StringComparer.Ordinal);
1117
1118 for (int index = 0;
1119 index <
1120 supplyChain.DistributionCenterSourcings.Count;
1121 index++)
1122 {
1123 DistributionCenterSourcing sourcing =
1124 supplyChain.DistributionCenterSourcings[index];
1125
1126 string path =
1127 "supplyChain.distributionCenterSourcings" +
1128 $"[{index}]";
1129
1130 if (!ItemExists(
1131 supplyChain,
1132 sourcing.ItemId))
1133 {
1134 AddError(
1135 issues,
1136 "SRC001",
1137 path + ".itemId",
1138 $"Item {sourcing.ItemId} does not exist.");
1139 }
1140
1141 if (!DistributionCenterExists(
1142 supplyChain,
1143 sourcing.DistributionCenterId))
1144 {
1145 AddError(
1146 issues,
1147 "SRC002",
1148 path + ".distributionCenterId",
1149 "The referenced distribution center does not exist.");
1150 }
1151
1152 ValidateWarehouseReference(
1153 supplyChain,
1154 sourcing.Warehouse,
1155 path + ".warehouse",
1156 issues);
1157
1158 string key =
1159 $"{sourcing.DistributionCenterId}:" +
1160 $"{sourcing.ItemId}:" +
1161 WarehouseKey(sourcing.Warehouse);
1162
1163 if (!keys.Add(key))
1164 {
1165 AddError(
1166 issues,
1167 "SRC003",
1168 path,
1169 "A sourcing relationship is duplicated.");
1170 }
1171
1172 bool inventoryExists =
1173 supplyChain.Inventories.Any(
1174 inventory =>
1175 inventory.ItemId ==
1176 sourcing.ItemId &&
1177 SameWarehouse(
1178 inventory.Warehouse,
1179 sourcing.Warehouse));
1180
1181 if (!inventoryExists)
1182 {
1183 AddError(
1184 issues,
1185 "SRC004",
1186 path + ".warehouse",
1187 "The sourcing relationship references an " +
1188 "item-warehouse inventory that does not exist.");
1189 }
1190
1191 bool demandExists =
1192 supplyChain.Demands.Any(
1193 demand =>
1194 demand.ItemId ==
1195 sourcing.ItemId &&
1196 demand.DistributionCenterId ==
1197 sourcing.DistributionCenterId);
1198
1199 if (!demandExists)
1200 {
1201 AddWarning(
1202 issues,
1203 "SRC005",
1204 path,
1205 "No demand is defined for this distribution " +
1206 "center and item.");
1207 }
1208
1209 if (!sourcing.HasValidDecisionConfiguration)
1210 {
1211 AddError(
1212 issues,
1213 "SRC006",
1214 path,
1215 "A backlog or shortage cost is defined without " +
1216 "the corresponding constraint.");
1217 }
1218
1219 ValidatePlanningHorizon(
1220 path,
1221 sourcing.HasDecisionParameters,
1222 sourcing.PlanningHorizon,
1224 supplyChain.PlanningHorizon,
1225 issues);
1226 }
1227 }
1228
1229 private static void ValidateSupplierDeliveries(
1230 SupplyChain supplyChain,
1231 ICollection<ValidationIssue> issues)
1232 {
1233 var keys =
1234 new HashSet<string>(StringComparer.Ordinal);
1235
1236 for (int index = 0;
1237 index < supplyChain.SupplierDeliveries.Count;
1238 index++)
1239 {
1240 SupplierDelivery delivery =
1241 supplyChain.SupplierDeliveries[index];
1242
1243 string path =
1244 $"supplyChain.supplierDeliveries[{index}]";
1245
1246 if (!SupplierExists(
1247 supplyChain,
1248 delivery.SupplierId))
1249 {
1250 AddError(
1251 issues,
1252 "SUP001",
1253 path + ".supplierId",
1254 "The referenced supplier does not exist.");
1255 }
1256
1257 if (!ItemExists(
1258 supplyChain,
1259 delivery.ItemId))
1260 {
1261 AddError(
1262 issues,
1263 "SUP002",
1264 path + ".itemId",
1265 $"Item {delivery.ItemId} does not exist.");
1266 }
1267
1268 ValidateWarehouseReference(
1269 supplyChain,
1270 delivery.Warehouse,
1271 path + ".warehouse",
1272 issues);
1273
1274 string key =
1275 $"{delivery.SupplierId}:" +
1276 $"{delivery.ItemId}:" +
1277 WarehouseKey(delivery.Warehouse);
1278
1279 if (!keys.Add(key))
1280 {
1281 AddError(
1282 issues,
1283 "SUP003",
1284 path,
1285 "A supplier-delivery relationship is duplicated.");
1286 }
1287
1288 if (delivery.LeadTime < 0)
1289 {
1290 AddError(
1291 issues,
1292 "SUP004",
1293 path + ".leadTime",
1294 "A supplier-delivery lead time cannot be negative.");
1295 }
1296
1297 bool inventoryExists =
1298 supplyChain.Inventories.Any(
1299 inventory =>
1300 inventory.ItemId ==
1301 delivery.ItemId &&
1302 SameWarehouse(
1303 inventory.Warehouse,
1304 delivery.Warehouse));
1305
1306 if (!inventoryExists)
1307 {
1308 AddError(
1309 issues,
1310 "SUP005",
1311 path + ".warehouse",
1312 "The delivery references an item-warehouse " +
1313 "inventory that does not exist.");
1314 }
1315
1316 if (delivery.HasDecisionParameters &&
1317 delivery.PlanningHorizon !=
1318 supplyChain.PlanningHorizon)
1319 {
1320 AddError(
1321 issues,
1322 "SUP006",
1323 path + ".purchasePrice",
1324 "The purchase-price time series does not use " +
1325 "the global planning horizon.");
1326 }
1327 }
1328 }
1329
1330 private static void ValidateWarehouseDecisionModel(
1331 Warehouse warehouse,
1332 string path,
1333 int globalHorizon,
1334 ICollection<ValidationIssue> issues)
1335 {
1336 if (!warehouse.HasValidCapacityConfiguration)
1337 {
1338 AddError(
1339 issues,
1340 "CAP001",
1341 path,
1342 "The warehouse additional-capacity configuration " +
1343 "is invalid.");
1344 }
1345
1346 ValidatePlanningHorizon(
1347 path,
1348 warehouse.HasDecisionParameters,
1349 warehouse.PlanningHorizon,
1351 globalHorizon,
1352 issues);
1353 }
1354
1355 private static void ValidateWorkCenterDecisionModel(
1356 WorkCenter workCenter,
1357 string path,
1358 int globalHorizon,
1359 ICollection<ValidationIssue> issues)
1360 {
1361 if (!workCenter.HasValidCapacityConfiguration)
1362 {
1363 AddError(
1364 issues,
1365 "CAP002",
1366 path,
1367 "The work-center additional-capacity configuration " +
1368 "is invalid.");
1369 }
1370
1371 ValidatePlanningHorizon(
1372 path,
1373 workCenter.HasDecisionParameters,
1374 workCenter.PlanningHorizon,
1376 globalHorizon,
1377 issues);
1378 }
1379
1380 private static void ValidateTransportResourceDecisionModel(
1381 TransportResource resource,
1382 string path,
1383 int globalHorizon,
1384 ICollection<ValidationIssue> issues)
1385 {
1386 if (!resource.HasValidCapacityConfiguration)
1387 {
1388 AddError(
1389 issues,
1390 "CAP003",
1391 path,
1392 "The transport-resource additional-capacity " +
1393 "configuration is invalid.");
1394 }
1395
1396 ValidatePlanningHorizon(
1397 path,
1398 resource.HasDecisionParameters,
1399 resource.PlanningHorizon,
1401 globalHorizon,
1402 issues);
1403 }
1404
1405 private static void ValidatePlanningHorizon(
1406 string path,
1407 bool hasActiveParameters,
1408 int localHorizon,
1409 bool internallyConsistent,
1410 int globalHorizon,
1411 ICollection<ValidationIssue> issues)
1412 {
1413 if (!internallyConsistent)
1414 {
1415 AddError(
1416 issues,
1417 "HOR001",
1418 path,
1419 "The active time series do not all use the same " +
1420 "planning horizon.");
1421 }
1422
1423 if (hasActiveParameters &&
1424 localHorizon != globalHorizon)
1425 {
1426 AddError(
1427 issues,
1428 "HOR002",
1429 path,
1430 $"The local planning horizon ({localHorizon}) " +
1431 $"does not match the global planning horizon " +
1432 $"({globalHorizon}).");
1433 }
1434 }
1435
1436 private static void ValidateWarehouseReference(
1437 SupplyChain supplyChain,
1438 WarehouseReference? reference,
1439 string path,
1440 ICollection<ValidationIssue> issues)
1441 {
1442 if (reference is null)
1443 {
1444 AddError(
1445 issues,
1446 "REF001",
1447 path,
1448 "A warehouse reference is required.");
1449
1450 return;
1451 }
1452
1453 if (reference.ReferenceId <= 0)
1454 {
1455 AddError(
1456 issues,
1457 "REF002",
1458 path + ".referenceId",
1459 "A warehouse reference identifier must be " +
1460 "strictly positive.");
1461 }
1462
1463 if (ResolveWarehouse(
1464 supplyChain,
1465 reference) is null)
1466 {
1467 AddError(
1468 issues,
1469 "REF003",
1470 path,
1471 $"Warehouse {WarehouseKey(reference)} does not exist.");
1472 }
1473 }
1474
1475 private static void ValidateIdentifiedCollection<T>(
1476 IEnumerable<T> values,
1477 Func<T, int> idSelector,
1478 Func<T, string> nameSelector,
1479 string path,
1480 string entityName,
1481 ICollection<ValidationIssue> issues)
1482 {
1483 // Track identifiers to detect duplicates.
1484 var identifiers = new HashSet<int>();
1485
1486 int index = 0;
1487
1488 foreach (T value in values)
1489 {
1490 int id = idSelector(value);
1491 string name = nameSelector(value);
1492
1493 string entityPath =
1494 $"{path}[{index}]";
1495
1496 if (id <= 0)
1497 {
1498 AddError(
1499 issues,
1500 "ID001",
1501 entityPath + ".id",
1502 $"A {entityName} identifier must be " +
1503 "strictly positive.");
1504 }
1505
1506 if (!identifiers.Add(id))
1507 {
1508 AddError(
1509 issues,
1510 "ID002",
1511 entityPath + ".id",
1512 $"{entityName} identifier {id} is duplicated.");
1513 }
1514
1515 if (string.IsNullOrWhiteSpace(name))
1516 {
1517 AddError(
1518 issues,
1519 "ID003",
1520 entityPath + ".name",
1521 $"A {entityName} name is required.");
1522 }
1523
1524 index++;
1525 }
1526 }
1527
1528 private static bool ItemExists(
1529 SupplyChain supplyChain,
1530 int itemId)
1531 {
1532 return supplyChain.Items.Any(
1533 item => item.Id == itemId);
1534 }
1535
1536 private static bool SupplierExists(
1537 SupplyChain supplyChain,
1538 int supplierId)
1539 {
1540 return supplyChain.Suppliers.Any(
1541 supplier => supplier.Id == supplierId);
1542 }
1543
1544 private static bool DistributionCenterExists(
1545 SupplyChain supplyChain,
1546 int distributionCenterId)
1547 {
1548 return supplyChain.DistributionCenters.Any(
1549 center =>
1550 center.Id == distributionCenterId);
1551 }
1552
1553 private static Plant? FindPlant(
1554 SupplyChain supplyChain,
1555 int plantId)
1556 {
1557 return supplyChain.Plants.FirstOrDefault(
1558 plant => plant.Id == plantId);
1559 }
1560
1561 private static TransportResource? FindTransportResource(
1562 SupplyChain supplyChain,
1563 int transportResourceId)
1564 {
1565 return supplyChain.TransportResources.FirstOrDefault(
1566 resource =>
1567 resource.Id == transportResourceId);
1568 }
1569
1570 private static WorkCenter? ResolveWorkCenter(
1571 SupplyChain supplyChain,
1572 WorkCenterReference? reference)
1573 {
1574 if (reference is null)
1575 {
1576 return null;
1577 }
1578
1579 Plant? plant =
1580 FindPlant(
1581 supplyChain,
1582 reference.PlantId);
1583
1584 return plant?.WorkCenters.FirstOrDefault(
1585 workCenter =>
1586 workCenter.Id ==
1587 reference.WorkCenterId);
1588 }
1589
1590 private static Warehouse? ResolveWarehouse(
1591 SupplyChain supplyChain,
1592 WarehouseReference? reference)
1593 {
1594 if (reference is null)
1595 {
1596 return null;
1597 }
1598
1599 // Different lookup strategy per warehouse kind.
1600 return reference.Kind switch
1601 {
1602 WarehouseReferenceKind.StandaloneWarehouse =>
1603 supplyChain.StandaloneWarehouses
1604 .FirstOrDefault(
1605 warehouse =>
1606 warehouse.Id ==
1607 reference.ReferenceId),
1608
1609 WarehouseReferenceKind.PlantWarehouse =>
1610 supplyChain.Plants
1611 .FirstOrDefault(
1612 plant =>
1613 plant.Id ==
1614 reference.ReferenceId)
1615 ?.Warehouse,
1616
1617 _ => null
1618 };
1619 }
1620
1621 private static bool SameWarehouse(
1622 WarehouseReference? first,
1623 WarehouseReference? second)
1624 {
1625 // Null-safe: both null = equal, only one null = not equal.
1626 if (first is null || second is null)
1627 {
1628 return first is null && second is null;
1629 }
1630
1631 return first.Kind == second.Kind &&
1632 first.ReferenceId == second.ReferenceId;
1633 }
1634
1635 private static bool SameWorkCenter(
1636 WorkCenterReference? first,
1637 WorkCenterReference? second)
1638 {
1639 // Null-safe: both null = equal, only one null = not equal.
1640 if (first is null || second is null)
1641 {
1642 return first is null && second is null;
1643 }
1644
1645 return first.PlantId == second.PlantId &&
1646 first.WorkCenterId == second.WorkCenterId;
1647 }
1648
1649 private static string WarehouseKey(
1650 WarehouseReference? reference)
1651 {
1652 return reference is null
1653 ? "<null>"
1654 : $"{reference.Kind}:{reference.ReferenceId}";
1655 }
1656
1657 private static string WorkCenterKey(
1658 WorkCenterReference? reference)
1659 {
1660 return reference is null
1661 ? "<null>"
1662 : $"{reference.PlantId}:" +
1663 $"{reference.WorkCenterId}";
1664 }
1665
1666 private static void AddError(
1667 ICollection<ValidationIssue> issues,
1668 string code,
1669 string path,
1670 string message)
1671 {
1672 issues.Add(
1673 new ValidationIssue(
1674 ValidationSeverity.Error,
1675 code,
1676 path,
1677 message));
1678 }
1679
1680 private static void AddWarning(
1681 ICollection<ValidationIssue> issues,
1682 string code,
1683 string path,
1684 string message)
1685 {
1686 issues.Add(
1687 new ValidationIssue(
1688 ValidationSeverity.Warning,
1689 code,
1690 path,
1691 message));
1692 }
1693}
int Id
Gets or sets the numerical identifier of the entity.
Represents a production plant.
Definition Plant.cs:19
List< WorkCenter > WorkCenters
Gets or sets the work centers belonging to the plant.
Definition Plant.cs:90
List< int > ManufacturedItemIds
Gets or sets the identifiers of the items the plant is declared to manufacture. An item may be declar...
Definition Plant.cs:117
bool ManufacturedItemIdsSpecified
Gets or sets whether the manufactured-item list was explicitly declared. An empty declared list diffe...
Definition Plant.cs:129
PlantWarehouse Warehouse
Gets or sets the warehouse attached to the plant.
Definition Plant.cs:67
WarehouseReference Destination
Gets or sets the destination warehouse.
WarehouseReference Origin
Gets or sets the origin warehouse.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
bool HasValidCapacityConfiguration
Gets a value indicating whether the dependencies between the capacity-related parameters are respecte...
bool HasDecisionParameters
Gets a value indicating whether at least one decision-model parameter is active.
CapacityConstraint? CapacityConstraint
Gets or sets the maximum regular capacity available for the transport resource during each planning p...
bool HasValidCapacityConfiguration
Gets a value indicating whether the dependencies between the warehouse-capacity parameters are respec...
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
bool HasDecisionParameters
Gets a value indicating whether the warehouse contains at least one global decision-model parameter.
CapacityConstraint? CapacityConstraint
Gets or sets the maximum global storage capacity of the warehouse during each planning period.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
int ReferenceId
Gets or sets the referenced identifier.
bool HasConsistentPlanningHorizon
Gets a value indicating whether every active parameter uses the same planning horizon.
bool HasValidCapacityConfiguration
Gets a value indicating whether the dependencies between capacity-related parameters are respected.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
bool HasDecisionParameters
Gets a value indicating whether at least one decision-model parameter is active.
int PlantId
Gets or sets the identifier of the plant owning the referenced work center.
int WorkCenterId
Gets or sets the identifier of the referenced work center.
int ItemId
Gets or sets the identifier of the requested item.
Definition Demand.cs:70
int PlanningHorizon
Gets the number of periods represented by the demand.
Definition Demand.cs:159
int DistributionCenterId
Gets or sets the identifier of the distribution center issuing the demand.
Definition Demand.cs:96
bool HasValidQuantities
Checks whether all currently stored demand quantities are finite and non-negative.
Definition Demand.cs:264
int DistributionCenterId
Gets or sets the identifier of the distribution center that can obtain the item from the referenced i...
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
WarehouseReference Warehouse
Gets or sets the warehouse holding the inventory from which the distribution center can obtain the it...
bool HasDecisionParameters
Gets a value indicating whether at least one decision-model parameter is active.
int ItemId
Gets or sets the identifier of the item contained in the referenced inventory.
bool HasValidDecisionConfiguration
Gets a value indicating whether the dependencies between service constraints and costs are respected.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
bool HasDecisionParameters
Gets a value indicating whether at least one optional decision-model parameter is active.
int ItemId
Gets or sets the identifier of the item stored in the warehouse.
Definition Inventory.cs:115
bool HasValidDecisionConfiguration
Gets a value indicating whether the direct dependencies between the inventory parameters are respecte...
WarehouseReference Warehouse
Gets or sets the warehouse storing the item.
Definition Inventory.cs:141
InventoryBalanceRule InventoryBalanceRule
Gets or sets the inventory-balance rule.
double InitialInventory
Gets or sets the initial inventory level.
Definition Inventory.cs:164
bool HasDecisionParameters
Gets a value indicating whether at least one production decision parameter is active.
WorkCenterReference WorkCenter
Gets or sets the referenced work center.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
int ItemId
Gets or sets the identifier of the item manufactured on the referenced work center.
Represents a production routing used to manufacture an item in a plant through one or more work cente...
List< WorkCenterReference > WorkCenters
Gets or sets the work centers used by this routing.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active routing parameters use the same planning horizon.
int ItemId
Gets or sets the identifier of the item manufactured through this routing.
int LeadTime
Gets or sets the production lead time.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent routing parameter.
bool HasLotSizingConstraints
Gets a value indicating whether at least one lot-sizing constraint is active.
int PlantId
Gets or sets the identifier of the plant in which this routing is available.
int PlanningHorizon
Gets the planning horizon represented by the purchase-price time series.
int SupplierId
Gets or sets the identifier of the supplier.
int ItemId
Gets or sets the identifier of the delivered item.
bool HasDecisionParameters
Gets a value indicating whether this delivery contains at least one decision-model parameter.
int LeadTime
Gets or sets the supplier-delivery lead time.
WarehouseReference Warehouse
Gets or sets the warehouse receiving the item.
int PlanningHorizon
Gets the planning horizon represented by the first active period-dependent parameter.
AdditionalCapacity? AdditionalCapacity
Gets or sets the maximum additional transport capacity available specifically for this item.
CapacityConstraint? CapacityConstraint
Gets or sets the maximum transport capacity available specifically for this item during each planning...
UnitCapacityConsumption? UnitCapacityConsumption
Gets or sets the transport capacity consumed by one unit of the item during each planning period.
AdditionalCapacityCost? AdditionalCapacityCost
Gets or sets the unit cost of additional transport capacity allocated to this item.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active parameters use the same planning horizon.
bool HasDecisionParameters
Gets a value indicating whether at least one decision-model parameter is active.
int ItemId
Gets or sets the identifier of the item transported by the referenced transport resource.
int TransportResourceId
Gets or sets the identifier of the transport resource associated with the item.
Represents the complete supply-chain data model.
List< Inventory > Inventories
Gets the item-warehouse inventories.
List< TransportResource > TransportResources
Gets the transport resources in the supply chain.
List< SupplierDelivery > SupplierDeliveries
Gets the supplier delivery possibilities.
List< DistributionCenterSourcing > DistributionCenterSourcings
Gets the warehouse sourcing options available to distribution centers.
List< ProductionCharacteristic > ProductionCharacteristics
Gets the item-work-center production characteristics.
int PlanningHorizon
Gets or sets the number of periods in the global planning horizon.
bool HasConsistentPlanningHorizon
Gets a value indicating whether all active time series use the global planning horizon.
List< TransportCharacteristic > TransportCharacteristics
Gets the item-transport-resource characteristics.
List< ProductionRouting > ProductionRoutings
Gets the production routings.
List< StandaloneWarehouse > StandaloneWarehouses
Gets the warehouses that are not attached to a plant.
List< Plant > Plants
Gets the plants in the supply chain.
List< ComponentRequirement > ComponentRequirements
Gets the bill-of-material component requirements.
List< Item > Items
Gets the items present in the supply chain.
List< TransportAssignment > TransportAssignments
List< DistributionCenter > DistributionCenters
Gets the distribution centers in the supply chain.
List< Supplier > Suppliers
Gets the suppliers in the supply chain.
List< Demand > Demands
Gets the demands expressed by distribution centers.
static void AppendIssues(SupplyChain supplyChain, ICollection< SupplyChainValidator.ValidationIssue > issues)
string Message
Gets the human-readable description of the issue.
string Code
Gets the stable technical code identifying the validation rule.
string Path
Gets the logical path of the model element concerned by the validation issue.
ValidationIssue(ValidationSeverity severity, string code, string path, string message)
Initializes a new validation issue.
ValidationSeverity Severity
Gets the severity of the validation issue.
Validates the structural, referential and decision-model consistency of a complete supply chain.
IReadOnlyList< ValidationIssue > ValidateTransportReadiness(SupplyChain supplyChain)
Advisory transport readiness diagnostics, independent of structural validity.
ValidationSeverity
Indicates the severity of a supply-chain validation issue.
@ Error
Indicates a validation error that makes the model invalid.
bool IsValid(SupplyChain supplyChain)
Determines whether a supply chain contains no validation error.
void ThrowIfInvalid(SupplyChain supplyChain)
Validates the model and throws an exception when at least one validation error is detected.
IReadOnlyList< ValidationIssue > Validate(SupplyChain supplyChain)
Validates a complete supply-chain model.
@ StandaloneWarehouse
The reference identifies a standalone warehouse through its own warehouse identifier e.