4using System.Threading.Tasks;
5using LotSizingDataModel.Core.PhysicalModel;
6using LotSizingDataModel.Core.Relationships;
7using LotSizingDataModel.Instance;
24 foreach (var characteristic
in instance.SupplyChain.TransportCharacteristics)
26 var resource = instance.SupplyChain.TransportResources.Single(r => r.Id == characteristic.TransportResourceId);
27 bool activate = options.IncludeResourceActivation && resource.FixedUsageCost is not
null;
28 bool setup = options.IncludeTransportSetups && (characteristic.FixedSetupCost is not
null || characteristic.SetupTime is not
null);
29 if (!activate && !setup)
continue;
30 foreach (var lane
in instance.SupplyChain.GetTransportLanes(resource.Id))
31 for (
int period = 1; period <= instance.PlanningHorizon; period++)
33 cancellationToken.ThrowIfCancellationRequested();
34 double bound = QuantityBound(resource, characteristic, period, options);
36 characteristic.ItemId, resource.Id, lane.Origin, lane.Destination, period));
42 AddConstraint(context, $
"transportResourceActivationLink_i{characteristic.ItemId}_r{resource.Id}_l{lane.Id}_t{period}",
53 AddConstraint(context, $
"transportSetupLink_i{characteristic.ItemId}_r{resource.Id}_l{lane.Id}_t{period}",
59 return ValueTask.CompletedTask;
62 private static double QuantityBound(TransportResource resource, TransportCharacteristic characteristic,
int period,
65 double unit = characteristic.UnitCapacityConsumption?[period] ?? 1;
66 double bound =
double.PositiveInfinity;
69 if (resource.CapacityConstraint is not
null)
70 bound = (resource.CapacityConstraint[period] + (options.IncludeAdditionalCapacity ? resource.AdditionalCapacity?[period] ?? 0 : 0)) / unit;
71 if (characteristic.CapacityConstraint is not
null)
72 bound = Math.Min(bound, (characteristic.CapacityConstraint[period] + (options.
IncludeAdditionalCapacity ? characteristic.AdditionalCapacity?[period] ?? 0 : 0)) / unit);
74 if (
double.IsFinite(bound))
return bound;
75 return options.TransportActivationBigM ??
throw new InvalidOperationException(
76 $
"Transport activation for item {characteristic.ItemId}, resource {resource.Id}, period {period} requires a finite capacity-derived quantity bound or explicit TransportActivationBigM.");
Provides a fluent builder for linear expressions.
LinearExpression Build(bool clone=true)
Builds and validates the linear expression.
Builds stable business-domain keys for mathematical variables and constraints.
string Build()
Builds the immutable domain-key text.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
Provides the shared state required while constructing a solver-independent mathematical model.
Creates canonical domain-key fragments shared by standard formulation builders and provides warehouse...
static MathematicalDomainKeyBuilder AddDestinationWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a destination warehouse reference.
static MathematicalDomainKeyBuilder AddOriginWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds an origin warehouse reference.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string TransportSetup
Identifies transport setup decision variables.
const string TransportResourceActivation
Identifies transport-resource activation decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
const string TransportResource
Transport-resource identifier segment.
const string Item
Item or product identifier segment.
const string Period
Period index segment.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.