LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
GlspChangeoverVariableFamilyBuilder.cs
Go to the documentation of this file.
1using LotSizingDataModel.Core.Relationships;
2using LotSizingDataModel.Instance;
6{
7 public override string FamilyId=>"glspChangeover";
8 protected override ValueTask BuildFamilyAsync(LotSizingInstance instance,MathematicalModelBuildContext context,StandardLotSizingFormulationOptions options,CancellationToken cancellationToken)
9 {
10 var (plantId,wc,profile)=GlspSchedulingData.GetSchedulingWorkCenter(instance);IReadOnlyList<ProductionRouting> routings=GlspSchedulingData.GetRoutings(instance,plantId,wc.Id);var ordered=profile.EnumerateMicroPeriods().ToArray();
11 for(int i=0;i<ordered.Length;i++)
12 {
13 var current=ordered[i];int fixedFrom=GlspSequenceSemantics.GetFixedPredecessorItemId(profile,i);
14 if(fixedFrom>0){foreach(var to in routings){if(to.ItemId==fixedFrom)continue;AddBinaryVariable(context,$"glspZ_i{fixedFrom}_j{to.ItemId}_t{current.MacroPeriod}_s{current.MicroPeriodIndex}",GlspFormulationVariableKeyFactory.CreateChangeoverKey(plantId,wc.Id,fixedFrom,to.ItemId,current),"GLSP initial-state changeover.");}continue;}
15 if(i==0||GlspSequenceSemantics.IsResetBoundary(profile,ordered[i-1],current))continue;
16 foreach(var from in routings)foreach(var to in routings){if(from.ItemId==to.ItemId)continue;AddBinaryVariable(context,$"glspZ_i{from.ItemId}_j{to.ItemId}_t{current.MacroPeriod}_s{current.MicroPeriodIndex}",GlspFormulationVariableKeyFactory.CreateChangeoverKey(plantId,wc.Id,from.ItemId,to.ItemId,current),"GLSP adjacent-state changeover.");}
17 }
18 return ValueTask.CompletedTask;
19 }
20}
Provides the shared state required while constructing a solver-independent mathematical model.
override string FamilyId
Gets the unique identifier of the variable family.
override ValueTask BuildFamilyAsync(LotSizingInstance instance, MathematicalModelBuildContext context, StandardLotSizingFormulationOptions options, CancellationToken cancellationToken)
static string CreateChangeoverKey(int plantId, int workCenterId, int fromItemId, int toItemId, ProductionMicroPeriodReference microPeriod)
static int WorkCenter ProductionSchedulingProfile Profile GetSchedulingWorkCenter(LotSizingInstance instance)
static IReadOnlyList< ProductionRouting > GetRoutings(LotSizingInstance instance, int plantId, int workCenterId)
static bool IsResetBoundary(ProductionSchedulingProfile profile, ProductionMicroPeriodReference previous, ProductionMicroPeriodReference current)
static int GetFixedPredecessorItemId(ProductionSchedulingProfile profile, int index)
Configures the standard solver-independent mixed-integer lot-sizing formulation.
Provides common validation and variable-registration helpers for one variable family of the standard ...
static MathematicalVariable AddBinaryVariable(MathematicalModelBuildContext context, string name, string domainKey, string description="")
Creates and registers one binary variable.