Class PSProblem
The PSProblem class models a single-machine scheduling problem
with production changeover costs, item-dependent stocking costs,
and demand constraints distributed over a finite planning horizon.
Each time period can be assigned to the production of one item or remain idle. The goal of the optimization is to minimize the total cost, which includes:
- Stocking costs — penalizing early production of items before their demand dates.
- Changeover costs — incurred when switching production between different items.
This class implements the Problem interface parameterized by PSState,
and defines all problem-specific behavior such as initial state construction,
variable domain generation, state transitions, and transition cost computation.
The structure of this problem is based on instances compatible with the PhD thesis of Vianney Coppe (2024).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRepresents the idle state of the machine (no production). -
Constructor Summary
ConstructorsConstructorDescriptionPSProblem(int nItems, int horizon, int[] stockingCost, int[][] changeoverCost, int[][] previousDemands) Constructs a PSP instance from explicit data arrays without a known optimal value.PSProblem(int nItems, int horizon, int[] stockingCost, int[][] changeoverCost, int[][] previousDemands, Optional<Double> optimal) Constructs a PSP instance from explicit data arrays and a known optimal value.Constructs a PSP instance from a data file. -
Method Summary
Modifier and TypeMethodDescriptionDefines the domain of feasible decisions (items to produce or idle) for a given state and time depth.doubleevaluate(int[] solution) Given a solution such thatsolution[i]is the value of the variablex_i, returns the value of this solution and checks if the solution respects the problem's constraints.Builds the initial problem state, where no items have been produced and the machine is idle.doubleReturns the initial objective value associated with the initial state.intnbVars()Returns the known optimal value of the problem, if available.voidAssigns a name to the problem instance for display or debugging purposes.toString()transition(PSState state, Decision decision) Applies a production decision to the current state and returns the resulting new state.doubletransitionCost(PSState state, Decision decision) Computes the cost incurred by executing a given decision from the current state.
-
Field Details
-
IDLE
public static final int IDLERepresents the idle state of the machine (no production).- See Also:
-
-
Constructor Details
-
PSProblem
public PSProblem(int nItems, int horizon, int[] stockingCost, int[][] changeoverCost, int[][] previousDemands, Optional<Double> optimal) Constructs a PSP instance from explicit data arrays and a known optimal value.- Parameters:
nItems- number of item typeshorizon- number of time periodsstockingCost- array of stocking costs for each item typechangeoverCost- matrix of changeover costs between item typespreviousDemands- matrix of previous demand indices for each item and timeoptimal- known optimal objective value (if available)
-
PSProblem
public PSProblem(int nItems, int horizon, int[] stockingCost, int[][] changeoverCost, int[][] previousDemands) Constructs a PSP instance from explicit data arrays without a known optimal value.- Parameters:
nItems- number of item typeshorizon- number of time periodsstockingCost- array of stocking costs for each item typechangeoverCost- matrix of changeover costs between item typespreviousDemands- matrix of previous demand indices for each item and time
-
PSProblem
Constructs a PSP instance from a data file.The file format is expected to contain:
- Horizon (number of time periods)
- Number of item types
- Number of orders
- Changeover cost matrix (
nItems × nItems) - Stocking costs for each item
- Demand matrix (
nItems × horizon) - Known optimal value (optional)
- Parameters:
filename- path to the input data file
-
-
Method Details
-
setName
Assigns a name to the problem instance for display or debugging purposes.- Parameters:
name- the name of the instance
-
optimalValue
Returns the known optimal value of the problem, if available.Note: This value should correspond to the expected output of the solver. For maximization problems, be careful with negative values.
- Specified by:
optimalValuein interfaceProblem<PSState>- Returns:
- an
Optionalcontaining the known optimal value, or empty if unknown
-
toString
-
nbVars
public int nbVars() -
initialValue
public double initialValue()Returns the initial objective value associated with the initial state.- Specified by:
initialValuein interfaceProblem<PSState>- Returns:
- the starting value of the objective function
-
initialState
Builds the initial problem state, where no items have been produced and the machine is idle.- Specified by:
initialStatein interfaceProblem<PSState>- Returns:
- the initial
PSStaterepresenting the start of the planning horizon
-
domain
Defines the domain of feasible decisions (items to produce or idle) for a given state and time depth.The domain depends on the remaining demands and available time periods. If there is insufficient time to satisfy all remaining demands, the domain becomes empty. Otherwise, the IDLE option may be included if there is enough slack in the schedule.
-
transition
Applies a production decision to the current state and returns the resulting new state.- Specified by:
transitionin interfaceProblem<PSState>- Parameters:
state- the current scheduling statedecision- the production decision (item index orIDLE)- Returns:
- the successor state after applying the decision
-
transitionCost
Computes the cost incurred by executing a given decision from the current state.The cost consists of two components:
- Stocking cost: proportional to how early the produced item is made relative to its next demand time.
- Changeover cost: cost of switching from the last produced item to the current one.
- Specified by:
transitionCostin interfaceProblem<PSState>- Parameters:
state- the current statedecision- the production decision (item or idle)- Returns:
- the transition cost incurred by the decision
-
evaluate
Description copied from interface:ProblemGiven a solution such thatsolution[i]is the value of the variablex_i, returns the value of this solution and checks if the solution respects the problem's constraints.Note: For maximization problems, the returned value is minus the computed value.
- Specified by:
evaluatein interfaceProblem<PSState>- Parameters:
solution- A solution of the problem.- Returns:
- The value of the input solution
- Throws:
InvalidSolutionException- If the solution does not respect problem's constraints.
-