LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
SmallBucketSetupCountConstraintFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Instance;
5
7
10{
11 public override string ConstraintFamilyId => "smallBucketMaximumSetupCount";
12 public override bool IsEnabled(LotSizingInstance instance,StandardLotSizingFormulationOptions options)
13 {
14 ArgumentNullException.ThrowIfNull(instance);ArgumentNullException.ThrowIfNull(options);
15 return instance.SupplyChain.WorkCenters.Any(w=>w.SchedulingProfile?.MaximumSetupCount is not null);
16 }
17 protected override ValueTask BuildConstraintsAsync(LotSizingInstance instance,MathematicalModelBuildContext context,StandardLotSizingFormulationOptions options,CancellationToken cancellationToken)
18 {
19 ProductionSchedulingProfile profile=instance.SupplyChain.WorkCenters.Single(w=>w.SchedulingProfile is not null).SchedulingProfile!;
20 MaximumSetupCount limit=profile.MaximumSetupCount ?? throw new InvalidOperationException("MaximumSetupCount is required.");
21 for(int period=1;period<=instance.PlanningHorizon;period++)
22 {
23 var expression=new LinearExpressionBuilder();
24 foreach(var routing in instance.SupplyChain.ProductionRoutings)
25 expression.Add(GetVariable(context,SmallBucketSchedulingDomainKeyFactory.CreateSetupStartKey(profile,routing,period)));
26 AddConstraint(context,$"smallBucketMaximumSetupCount_t{period}",expression.Build(),MathematicalConstraintSense.LessThanOrEqual,limit.GetCount(period));
27 }
28 return ValueTask.CompletedTask;
29 }
30}
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
MathematicalModel Build(bool clone=true)
Builds and validates the mathematical model.
static string CreateSetupStartKey(ProductionSchedulingProfile profile, ProductionRouting routing, int period)
override ValueTask BuildConstraintsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
override bool IsEnabled(LotSizingInstance instance, StandardLotSizingFormulationOptions options)
Determines whether this constraint family is enabled.
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.