meio_general
Module¶
Overview¶
For MEIO systems with arbitrary topology (not necessarily serial or tree systems),
the meio_general
module can optimize base-stock levels approximately using
relatively brute-force approaches—either coordinate descent or enumeration. These
heuristics tend to be quite slow and not particularly accurate, but they are sometimes
the best methods available for complex systems that are not well solved in the literature.
Note
The terms “node” and “stage” are used interchangeably in the documentation.
Note
The notation and references (equations, sections, examples, etc.) used below refer to Snyder and Shen, Fundamentals of Supply Chain Theory (FoSCT), 2nd edition (2019).
See Also
For an overview of multi-echelon inventory optimization in Stockpyl, see the tutorial page for multi-echelon inventory optimization.
API Reference¶
- meio_by_enumeration(network, base_stock_levels=None, truncation_lo=None, truncation_hi=None, discretization_step=None, discretization_num=None, groups=None, objective_function=None, sim_num_trials=10, sim_num_periods=1000, sim_rand_seed=None, progress_bar=True, print_solutions=False)[source]¶
Optimize the MEIO instance by enumerating the combinations of values of the base-stock levels. Evaluate each combination using the provided objective function, or simulation if not provided.
- Parameters
network (
SupplyChainNetwork
) – The network to optimize.base_stock_levels (dict, optional) – A dictionary indicating, for each node index, the base-stock levels to test in the enumeration. Example: {0: [0, 5, 10, 15], 1: [0, 2, 4, 6]}.
truncation_lo (float or dict, optional) – A float or dictionary indicating, for each node index, the low end of the truncation range for values to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
truncation_hi (float or dict, optional) – A dictionary indicating, for each node index, the high end of the truncation range for values levels to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
discretization_step (float or dict, optional) – A dictionary indicating, for each node index, the interval width to use for discretization of the values to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
discretization_num (int or dict, optional) – A dictionary indicating, for each node index, the number of intervals to use for discretization of the values to test for that node. If int, the same value is used for every node. If omitted, it is set automatically. Ignored if
discretization_step
is provided.groups (list of sets, optional) – A list of sets, each of which contains indices of nodes that should have the same base-stock level. This speeds the optimization since the base-stock levels for the nodes in a given group do not have to be optimized individually. Any nodes not contained in any set in the list are optimized individually. If omitted, all nodes are optimized individually.
objective_function (function, optional) – The function to use to evaluate a given solution. The function must take a single argument, the dictionary of base-stock levels, and return a single output, the expected cost per period. If omitted, simulation will be used.
sim_num_trials (int, optional) – Number of trials to run in each simulation. Ignored if
objective_function
is provided.sim_num_periods (int, optional) – Number of periods per trial in each simulation. Ignored if
objective_function
is provided.sim_rand_seed (int, optional) – Rand seed to use for simulation. Ignored if
objective_function
is provided.progress_bar (bool, optional) – Display a progress bar? Ignored if
print_solutions
isTrue
.print_solutions (bool, optional) – Print each solution and its cost?
- Returns
best_S (dict) – Dict of best base-stock levels found.
best_cost (float) – Best cost found.
- meio_by_coordinate_descent(network, initial_solution=None, search_lo=None, search_hi=None, groups=None, objective_function=None, sim_num_trials=10, sim_num_periods=1000, sim_rand_seed=None, tol=0.01, line_search_tol=0.0001, verbose=False)[source]¶
Optimize the MEIO instance by coordinate descent on the base-stock levels. Evaluate each solution using the provided objective function, or simulation if not provided.
- Parameters
network (
SupplyChainNetwork
) – The network to optimize.initial_solution (dict, optional) – The starting solution, as a dict. If omitted, initial solution will be set automatically.
search_lo (float or dict, optional) – A float or dictionary indicating, for each node index, the low end of the search range for that node. If float, the same value is used for every node. If omitted, it is set automatically.
search_hi (float or dict, optional) – A dictionary indicating, for each node index, the high end of the search range for that node. If float, the same value is used for every node. If omitted, it is set automatically.
groups (list of sets, optional) – A list of sets, each of which contains indices of nodes that should have the same base-stock level. This speeds the optimization since the base-stock levels for the nodes in a given group do not have to be optimized individually. Any nodes not contained in any set in the list are optimized individually. If omitted, all nodes are optimized individually.
objective_function (function, optional) – The function to use to evaluate a given solution. If omitted, simulation will be used.
sim_num_trials (int, optional) – Number of trials to run in each simulation. Ignored if
objective_function
is provided.sim_num_periods (int, optional) – Number of periods per trial in each simulation. Ignored if
objective_function
is provided.sim_rand_seed (int, optional) – Rand seed to use for simulation. Ignored if
objective_function
is provided.tol (float, optional) – Algorithm terminates when iteration fails to improve objective function by more than tol.
line_search_tol (float, optional) – Tolerance to use for line search (golden section search) component of algorithm.
verbose (bool, optional) – Set to True to print messages at each iteration.
- Returns
best_S (dict) – Dict of best base-stock levels found.
best_cost (float) – Best cost found.
- truncate_and_discretize(node_indices, values=None, truncation_lo=None, truncation_hi=None, discretization_step=None, discretization_num=None)[source]¶
Determine truncated and discretized set of values for each node in network.
If
values
is provided, it is assumed to be a dictionary of truncated and discretized values, and it is returned without modification.If
truncation_lo
,truncation_hi
, anddiscretization_step
ordiscretization_num
are provided, these are used to determine the set of values.truncation_lo
,truncation_hi
,discretization_step
, anddiscretization_num
may each either be a dictionary (with keys equal to node indices) or a singleton. If a singleton, the same value will be used for all nodes.If any or all of
truncation_lo
,truncation_hi
,discretization_step
, anddiscretization_num
are omitted, they will be set automatically:truncation_lo
is set to 0.truncation_hi
is set to 100.discretization_step
is set to 1 anddiscretization_num
is set to (truncation_hi
-truncation_lo
) /discretization_step
.
- Parameters
node_indices (list) – List of indices of all nodes in the network.
values (dict, optional) – Dictionary in which keys are node indices and values are lists of truncated, discretized values; if provided, it is returned without modification.
truncation_lo (float or dict, optional) – A float or dictionary indicating, for each node index, the low end of the truncation range for values to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
truncation_hi (float or dict, optional) – A dictionary indicating, for each node index, the high end of the truncation range for values levels to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
discretization_step (float or dict, optional) – A dictionary indicating, for each node index, the interval width to use for discretization of the values to test for that node. If float, the same value is used for every node. If omitted, it is set automatically.
discretization_num (int or dict, optional) – A dictionary indicating, for each node index, the number of intervals to use for discretization of the values to test for that node. If int, the same value is used for every node. If omitted, it is set automatically. Ignored if
discretization_step
is provided.
- Returns
truncated_discretized_values – Dictionary indicating a list of truncated, discretized values for each node index.
- Return type
dict