LotSizingDataModel.Solver 2.0.1
Solver-independent modeling, execution, monitoring and adapter infrastructure.
Loading...
Searching...
No Matches
DeliveryRevenueObjectiveTermBuilder.cs
Go to the documentation of this file.
1using System.Threading;
2using System.Threading.Tasks;
3using LotSizingDataModel.Core.Relationships;
4using LotSizingDataModel.Instance;
7
9
10/// <summary>
11/// Subtracts sales revenue from the minimized standard
12/// objective.
13/// </summary>
16{
17 /// <summary>
18 /// Gets the objective-term family identifier.
19 /// </summary>
20 public override string TermFamilyId =>
21 "deliveryRevenue";
22
23 /// <summary>
24 /// Builds negative delivered-quantity revenue terms.
25 /// </summary>
26 protected override ValueTask BuildTermsAsync(
27 LotSizingInstance instance,
29 LinearExpressionBuilder expressionBuilder,
31 CancellationToken cancellationToken)
32 {
33 foreach (
34 DistributionCenterSourcing sourcing
35 in instance.SupplyChain.DistributionCenterSourcings)
36 {
37 for (
38 int period = 1;
39 period <= instance.PlanningHorizon;
40 period++)
41 {
42 cancellationToken.ThrowIfCancellationRequested();
43
44 var keyBuilder =
47 .Add(
49 sourcing.DistributionCenterId)
50 .Add(
52 sourcing.ItemId);
53
55 keyBuilder,
56 sourcing.Warehouse);
57
59 context,
60 expressionBuilder,
61 keyBuilder
62 .Add(
64 period)
65 .Build(),
66 -(sourcing.SellingPrice?[period] ??
67 0.0));
68 }
69 }
70
71 return ValueTask.CompletedTask;
72 }
73}
Provides a fluent builder for linear expressions.
Builds stable business-domain keys for mathematical variables and constraints.
MathematicalDomainKeyBuilder Add(string name, string value)
Adds a text segment.
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)
Builds negative delivered-quantity revenue terms.
Creates canonical domain-key fragments shared by standard formulation builders and provides warehouse...
static MathematicalDomainKeyBuilder AddWarehouse(MathematicalDomainKeyBuilder builder, WarehouseReference warehouse)
Adds a warehouse reference using the generic warehouse or plant segment.
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.
Provides the canonical mathematical domain-key categories used to identify lot-sizing decision famili...
const string Delivery
Identifies delivered-quantity decision variables.
Provides the canonical mathematical domain-key segment names used by lot-sizing variables and constra...
const string DistributionCenter
Distribution-center identifier segment.