LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspMicroProductionLinkConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
7{
8 public override string ConstraintFamilyId=>"glspMicroProductionLink";
9 protected override ValueTask BuildConstraintsAsync(LotSizingInstance instance,MathematicalModelBuildContext context,StandardLotSizingFormulationOptions options,CancellationToken cancellationToken){var (plantId,wc,profile)=GlspSchedulingData.GetSchedulingWorkCenter(instance);var routings=GlspSchedulingData.GetRoutings(instance,plantId,wc.Id);foreach(var m in profile.EnumerateMicroPeriods()){double cap=wc.CapacityConstraint![m.MacroPeriod]+(wc.AdditionalCapacity?[m.MacroPeriod]??0.0);foreach(var r in routings){var c=GlspSchedulingData.GetCharacteristic(instance,r,plantId,wc.Id);AddConstraint(context,$"glspProductionLink_r{r.Id}_t{m.MacroPeriod}_s{m.MicroPeriodIndex}",new LinearExpressionBuilder().Add(GetVariable(context,GlspFormulationVariableKeyFactory.CreateMicroProductionKey(plantId,wc.Id,r.Id,r.ItemId,m)),c.UnitCapacityConsumption![m.MacroPeriod]).Subtract(GetVariable(context,GlspFormulationVariableKeyFactory.CreateMicroSetupStateKey(plantId,wc.Id,r.Id,r.ItemId,m)),cap).Build(),MathematicalConstraintSense.LessThanOrEqual,0.0);}}return ValueTask.CompletedTask;}
10}
Provides a fluent builder for linear expressions.
LinearExpressionBuilder Subtract(MathematicalVariable variable, double coefficient=1.0)
Subtracts a variable term from the expression.
LinearExpression Build(bool clone=true)
Builds and validates the linear expression.
Provides the shared state required while constructing a solver-independent mathematical model.
static string CreateMicroSetupStateKey(int plantId, int workCenterId, int routingId, int itemId, ProductionMicroPeriodReference microPeriod)
static string CreateMicroProductionKey(int plantId, int workCenterId, int routingId, int itemId, ProductionMicroPeriodReference microPeriod)
static int WorkCenter ProductionSchedulingProfile Profile GetSchedulingWorkCenter(LotSizingInstance instance)
static ProductionCharacteristic GetCharacteristic(LotSizingInstance instance, ProductionRouting routing, int plantId, int workCenterId)
static IReadOnlyList< ProductionRouting > GetRoutings(LotSizingInstance instance, int plantId, int workCenterId)
Provides common validation and helper methods for one constraint family of the standard lot-sizing fo...
static MathematicalVariable GetVariable(MathematicalModelBuildContext context, string domainKey)
Resolves a required variable from its canonical domain key.
static void AddConstraint(MathematicalModelBuildContext context, string name, LinearExpression expression, MathematicalConstraintSense sense, double rightHandSide, string domainKey="", string description="")
Adds one linear constraint to the mathematical model.
Configures the standard solver-independent mixed-integer lot-sizing formulation.
MathematicalConstraintSense
Identifies the relational sense of a mathematical constraint.