LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspChangeoverCostObjectiveTermBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.DecisionModel.Scheduling;
2using LotSizingDataModel.Core.Relationships;
3using LotSizingDataModel.Instance;
8{
9 public override string TermFamilyId=>"glspChangeoverCost";
10 protected override ValueTask BuildTermsAsync(LotSizingInstance instance,MathematicalModelBuildContext context,LinearExpressionBuilder expressionBuilder,StandardLotSizingFormulationOptions options,CancellationToken cancellationToken)
11 {
12 var (plantId,wc,profile)=GlspSchedulingData.GetSchedulingWorkCenter(instance);var routings=GlspSchedulingData.GetRoutings(instance,plantId,wc.Id);
13 foreach(var m in profile.EnumerateMicroPeriods())foreach(var from in routings)foreach(var to in routings){if(from.ItemId==to.ItemId)continue;string key=GlspFormulationVariableKeyFactory.CreateChangeoverKey(plantId,wc.Id,from.ItemId,to.ItemId,m);if(!context.VariableRegistry.TryGet(key,out MathematicalVariable? variable)||variable is null)continue;double cost=GlspSchedulingData.FindChangeover(profile,from.ItemId,to.ItemId)?.ChangeoverCost?[m.MacroPeriod]??0.0;if(cost!=0)AddCostTerm(context,expressionBuilder,key,cost);}
14 return ValueTask.CompletedTask;
15 }
16}
Provides a fluent builder for linear expressions.
Provides the shared state required while constructing a solver-independent mathematical model.
override ValueTask BuildTermsAsync(LotSizingInstance instance, MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
override string TermFamilyId
Gets the unique identifier of the objective-term family.
static string CreateChangeoverKey(int plantId, int workCenterId, int fromItemId, int toItemId, ProductionMicroPeriodReference microPeriod)
static ? ProductionChangeover FindChangeover(ProductionSchedulingProfile profile, int fromItemId, int toItemId)
static int WorkCenter ProductionSchedulingProfile Profile GetSchedulingWorkCenter(LotSizingInstance instance)
static IReadOnlyList< ProductionRouting > GetRoutings(LotSizingInstance instance, int plantId, int workCenterId)
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides common validation and helper methods for one objective-term family of the standard lot-sizin...
static void AddCostTerm(MathematicalModelBuildContext context, LinearExpressionBuilder expressionBuilder, string domainKey, double coefficient)
Adds one variable cost term to the shared objective.
Represents one decision variable in a mathematical optimization model.