optimization-ai999x: capability guide

Creator / engineer: Ibnul Jaif Farabi · Company: AI999X. Ask the package Who created you? or call optimization_ai999x.about() for the same answer.

Every capability optimization-ai999x supports, generated from its certified capability contracts. Every example below was executed when this guide was built. The structured call solve("<capability id>", ...) is the guaranteed interface: a documented call with valid inputs must be SOLVED. Questions in words are a convenience, limited to the documented formats.

Quick start

import optimization_ai999x

result = optimization_ai999x.solve('linear_program', sense='maximize', c='3, 5', A='1 0; 0 2; 3 2', b='4, 12, 18')
result.show()
# optimal_value = 36, x = [2.0, 6.0], solution_unique = yes, shadow_prices = [0.0, 1.5, 1.0]

By topic

topiccapabilities
Calculus optimisation / geometryLargest rectangle for a given length of fencing, Open box of maximum volume from a rectangular sheet, Closed cylinder of least surface area for a given volume
Calculus optimisation / one variableAbsolute extrema of a polynomial on a closed interval
Calculus optimisation / several variablesCritical point of a two-variable quadratic and its classification
Cost-volume-profit analysisBreak-even quantity
Dynamic programming / inventoryDynamic lot sizing (Wagner-Whitin)
Dynamic programming / Markov decision processesDiscounted Markov decision process (optimal values and policy)
Economic optimisation / monopoly pricingProfit-maximising output with linear demand
Economic optimisation / pricingRevenue-maximising price with linear demand
Game theory / non-zero-sum gamesPure-strategy Nash equilibria of a bimatrix game, Mixed-strategy Nash equilibrium of a 2 x 2 game
Game theory / zero-sum gamesTwo-person zero-sum game (value and optimal mixed strategies), 2 x 2 zero-sum game (saddle point or mixed-strategy formula)
Integer programmingInteger linear program (branch and bound)
Integer programming / coveringMinimum-cost set cover, Minimum vertex cover (and maximum independent set)
Integer programming / graph colouringChromatic number (minimum graph colouring)
Integer programming / knapsack0/1 knapsack problem, Unbounded knapsack problem
Integer programming / locationUncapacitated facility location
Integer programming / packingBin packing (minimum number of bins)
Inventory managementEconomic order quantity (EOQ), EOQ with planned backorders, Economic production quantity (EPQ), Order quantity with quantity discounts (all-units), Reorder point with safety stock, Periodic-review order-up-to level
Inventory management / single-periodNewsvendor order quantity (normal demand), Newsvendor order quantity (uniform demand), Newsvendor order quantity (discrete demand)
Linear programmingLinear program (simplex method), Two-variable linear program (graphical corner-point method)
Linear programming / sensitivity analysisShadow prices of a linear program
Multi-criteria decision analysisTOPSIS ranking (closeness to the ideal solution), Weighted sum model (simple additive weighting), Weighted product model
Multi-criteria decision analysis / AHPAHP priority vector (principal eigenvector), AHP consistency ratio, AHP weights by the geometric mean method
Network optimisation / assignmentAssignment problem (Hungarian method), minimum total cost, Assignment problem (Hungarian method), maximum total value
Network optimisation / flowsMaximum flow and minimum cut (Edmonds-Karp), Minimum-cost flow (transshipment)
Network optimisation / matchingMaximum bipartite matching, Maximum-weight matching (general graph)
Network optimisation / routingTravelling salesman tour (exact, Held-Karp)
Network optimisation / shortest routesShortest path (Dijkstra's algorithm), Shortest path with negative weights (Bellman-Ford), All-pairs shortest distances (Floyd-Warshall)
Network optimisation / spanning treesMinimum spanning tree (Kruskal's algorithm)
Network optimisation / transportationTransportation problem (minimum shipping cost)
Nonlinear optimisation / descent methodsSteepest descent step with exact line search (quadratic)
Nonlinear optimisation / quadraticUnconstrained quadratic minimisation, Equality-constrained quadratic program (Lagrange multipliers / KKT)
Project schedulingCritical path method (project duration and slack), PERT project duration and completion probability
Queueing theoryM/M/1 queue, M/M/c queue (Erlang C), M/M/c/K queue (finite capacity), Machine-repair (finite-source) queue, M/G/1 queue (Pollaczek-Khinchine formula)
Queueing theory / staffingMinimum number of servers for a service target (Erlang C)
Queueing theory / teletrafficErlang B blocking probability (M/M/c/c loss system)
Revenue managementLittlewood's rule (two-fare protection level)
Scheduling / flow shopJohnson's rule (two-machine flow shop)
Scheduling / parallel machinesMinimum makespan on identical parallel machines
Scheduling / single machineShortest processing time rule (minimum mean flow time), Weighted shortest processing time (Smith's rule), Earliest due date rule (minimum maximum lateness), Moore-Hodgson algorithm (minimum number of tardy jobs)
Unconstrained optimisation / one variableOptimum of a quadratic function

Outcomes

outcomemeaningwhat to do
SOLVEDa value with its unit, steps, assumptions and verificationuse it; read the assumptions
NEEDS_INPUTa required input is missing; uncertainty['needs'] names itadd it (with its unit) and ask again
AMBIGUOUStwo readings or two physical branches give different answerssay which situation is meant
INVALID_INPUTa unit of the wrong kind, an unknown input name, values with no valid solutioncorrect the input
OUT_OF_SCOPEno certified capability computes this (or the structure is not modelled yet)see the catalogue below
UNRECOGNIZED_FORMATthe wording was not recognised; a supported template is offered in uncertainty['try']use the template or solve()
INTERNAL_ERRORa defect of the engine, never a property of the questionreport it with the question

Result fields

fieldmeaning
value, unitthe result in SI units
valuesevery output of a procedure (x1, x2, discriminant ...)
outcomeone of the seven outcomes above
stepseach equation used, its inputs (with where each came from) and its result
assumptionsconditions and declared defaults the answer relies on
verificationresidual of every equation, dimensional consistency, independent checks
latex()the derivation as LaTeX
show()renders in a notebook, prints in a terminal

Common mistakes

Procedures: algorithms with several outputs

Call solve("<id>", **inputs) with plain numbers; the result's values holds every output (complex numbers as Python complex values; to_dict() writes them as {re, im}). Each result is substituted back into its defining equation before it is returned.

idoperationinputsoutputs
linear_programLinear program (simplex method)sense, c, A, b, relationsoptimal_value, x, solution_unique, shadow_prices
lp_two_variable_graphicalTwo-variable linear program (graphical corner-point method)sense, c, A, b, relationsoptimal_value, x, y, optimal_corners, corner_points, solution_unique
integer_programInteger linear program (branch and bound)sense, c, A, b, relationsoptimal_value, x_one_optimal, nodes
lp_shadow_pricesShadow prices of a linear programsense, c, A, b, relationsshadow_prices, optimal_value, x, solution_unique
quadratic_optimumOptimum of a quadratic functiona, b, c, goalx_opt, f_opt, type
break_even_pointBreak-even quantityF_, p, vquantity, revenue, contribution_margin
profit_max_linear_demandProfit-maximising output with linear demanda, b, cv, F_quantity, price, profit
revenue_max_linear_demandRevenue-maximising price with linear demandalpha, betaprice, quantity, revenue
fence_max_areaLargest rectangle for a given length of fencingL, wallwidth, length, max_area
open_box_max_volumeOpen box of maximum volume from a rectangular sheetL, Wcut, max_volume
can_min_surfaceClosed cylinder of least surface area for a given volumeVradius, height, min_area
eoqEconomic order quantity (EOQ)D, S, HQ, total_cost, orders_per_period, cycle_time
eoq_planned_shortagesEOQ with planned backordersD, S, H, BQ, max_backorder, max_inventory, total_cost
epq_production_lotEconomic production quantity (EPQ)D, P, S, HQ, max_inventory, total_cost, runs_per_period
eoq_quantity_discountOrder quantity with quantity discounts (all-units)D, S, i_rate, breaks, pricesorder_quantity, total_cost, unit_price
reorder_pointReorder point with safety stockd, L, sigma, SLreorder_point, safety_stock, z, lead_time_demand
order_up_to_levelPeriodic-review order-up-to leveld, sigma, R, L, SLorder_up_to_level, safety_stock, z
newsvendor_normalNewsvendor order quantity (normal demand)p, c, mu, sigma, scritical_ratio, Q, expected_profit, expected_shortage
newsvendor_uniformNewsvendor order quantity (uniform demand)p, c, lo, hi, scritical_ratio, Q, expected_profit
newsvendor_discreteNewsvendor order quantity (discrete demand)p, c, demands, probs, scritical_ratio, Q, expected_profit
littlewood_protectionLittlewood's rule (two-fare protection level)p1, p2, mu, sigma, capacityprotection_level, z, booking_limit
mm1_queueM/M/1 queuelam, murho, L, Lq, W, Wq, P0
mmc_queueM/M/c queue (Erlang C)lam, mu, crho, P_wait, Lq, Wq, W, L, P0
mmck_finite_queueM/M/c/K queue (finite capacity)lam, mu, c, KP_block, lam_eff, L, Lq, W, Wq, P0
erlang_bErlang B blocking probability (M/M/c/c loss system)A, cblocking_probability, carried_traffic, lost_traffic
machine_repair_queueMachine-repair (finite-source) queueN, lam, mu, cL, Lq, lam_eff, W, Wq, P0, working
mg1_pollaczek_khinchineM/G/1 queue (Pollaczek-Khinchine formula)lam, ES, sdrho, Lq, L, Wq, W
mmc_staffingMinimum number of servers for a service target (Erlang C)lam, mu, target, criterionservers, P_wait, Wq, utilisation
spt_mean_flow_timeShortest processing time rule (minimum mean flow time)pmean_flow_time, total_completion_time, sequence
wspt_weighted_completionWeighted shortest processing time (Smith's rule)p, wweighted_completion_time, sequence
edd_max_latenessEarliest due date rule (minimum maximum lateness)p, dmax_lateness, max_tardiness, sequence, tardy_jobs_in_sequence
moore_hodgson_tardy_jobsMoore-Hodgson algorithm (minimum number of tardy jobs)p, dmin_tardy_jobs, on_time_sequence, tardy_jobs
johnson_two_machineJohnson's rule (two-machine flow shop)a, bmakespan, sequence
parallel_machine_makespanMinimum makespan on identical parallel machinesp, mmakespan, machine_of_job, lower_bound
critical_path_methodCritical path method (project duration and slack)durations, precedencesproject_duration, critical_activities, slack, earliest_start, latest_start
pert_projectPERT project duration and completion probabilitytimes, precedences, deadlineexpected_duration, variance, std_dev, critical_path, expected_times, probability
shortest_pathShortest path (Dijkstra's algorithm)edges, source, target, directeddistance, path, path_unique
bellman_ford_shortest_pathShortest path with negative weights (Bellman-Ford)edges, source, targetdistance, distances_from_source
all_pairs_shortest_pathsAll-pairs shortest distances (Floyd-Warshall)edges, directeddistances, nodes, diameter
minimum_spanning_treeMinimum spanning tree (Kruskal's algorithm)edgestotal_weight, tree_edges, tree_unique
max_flowMaximum flow and minimum cut (Edmonds-Karp)edges, source, targetmax_flow, min_cut_source_side, edge_flows
transportation_problemTransportation problem (minimum shipping cost)supply, demand, costmin_cost, shipments, plan_unique, dual
min_cost_flowMinimum-cost flow (transshipment)capacity, cost, supplymin_cost, flows, flow_unique, dual
assignment_min_costAssignment problem (Hungarian method), minimum total costCmin_cost, assignment, assignment_unique, dual_u, dual_v
assignment_max_profitAssignment problem (Hungarian method), maximum total valueCmax_value, assignment, assignment_unique, dual_u, dual_v
bipartite_matchingMaximum bipartite matchingedgesmax_matching, matching_example, vertex_cover
max_weight_matchingMaximum-weight matching (general graph)edgesmax_weight, matching_example
traveling_salesmanTravelling salesman tour (exact, Held-Karp)Dmin_tour_length, tour_example
knapsack_010/1 knapsack problemvalues, weights, capacitymax_value, items_example, total_weight
knapsack_unboundedUnbounded knapsack problemvalues, weights, capacitymax_value, copies_example
set_coverMinimum-cost set coversets, costsmin_cost, sets_example
facility_locationUncapacitated facility locationfixed, costmin_cost, open_example
bin_packingBin packing (minimum number of bins)sizes, capacitymin_bins, bin_of_item, lower_bound
zero_sum_gameTwo-person zero-sum game (value and optimal mixed strategies)Avalue, row_strategy_example, col_strategy_example
zero_sum_2x22 x 2 zero-sum game (saddle point or mixed-strategy formula)Avalue, saddle_point, p_row1, q_col1
pure_nash_equilibriaPure-strategy Nash equilibria of a bimatrix gameA, Bcount, equilibria
mixed_nash_2x2Mixed-strategy Nash equilibrium of a 2 x 2 gameA, Bp_row1, q_col1, row_payoff, col_payoff
topsisTOPSIS ranking (closeness to the ideal solution)X, w, typesscores, best_score, best
weighted_sum_modelWeighted sum model (simple additive weighting)X, w, typesscores, best_score, best
weighted_product_modelWeighted product modelX, w, typesscores, best_score, best
ahp_priority_vectorAHP priority vector (principal eigenvector)judgmentsweights, lambda_max, best
ahp_consistency_ratioAHP consistency ratiojudgmentsCR, CI, lambda_max, weights, acceptable
ahp_geometric_meanAHP weights by the geometric mean methodjudgmentsweights, max_weight, best
unconstrained_quadratic_minUnconstrained quadratic minimisationQ, cf_min, x_star
equality_constrained_qpEquality-constrained quadratic program (Lagrange multipliers / KKT)Q, c, A, bf_min, x_star, multipliers
steepest_descent_stepSteepest descent step with exact line search (quadratic)Q, c, x0alpha, x1, f1, gradient
critical_point_two_variablesCritical point of a two-variable quadratic and its classificationa, b, c, d, e, f0f_value, x, y, type
polynomial_extrema_intervalAbsolute extrema of a polynomial on a closed intervalcoefficients, lo, himin_value, max_value, argmin_example, argmax_example
wagner_whitin_lot_sizingDynamic lot sizing (Wagner-Whitin)demand, K, hmin_cost, order_quantities_example, orders
mdp_discountedDiscounted Markov decision process (optimal values and policy)R, T, gammavalue_state_1, values, policy
graph_coloringChromatic number (minimum graph colouring)edgeschromatic_number, coloring_example, nodes
minimum_vertex_coverMinimum vertex cover (and maximum independent set)edgesmin_cover_size, cover_example, max_independent_set_size

Linear program (simplex method) — linear_program

Optimise a linear objective subject to linear constraints with non-negative variables: the optimal value, an optimal solution (stated as unique only when it is) and the shadow prices.

\[\max / \min \; c^\top x \quad \text{s.t. } A x \;(\le, \ge, =)\; b,\; x \ge 0\]
inputmeaningcondition
sensemaximize or minimize
cobjective coefficients, one per variable
Aconstraint coefficients, one row per constraint
bright-hand sides, one per constraint
relationsrelation of each constraint: <=, >= or = (default all <=)
outputmeaning
optimal_valueoptimal value of the objective
xthe optimal solution, variables in order of first appearance (only when unique; otherwise x_one_optimal)
solution_uniqueyes when the optimal solution is unique
shadow_priceschange of the optimal value per unit increase of each right-hand side (only when unique; otherwise dual_one_optimal)
Linear program (simplex method): change of the optimal value per unit increase of each right-hand side (onl…change of the optimal value per unit increase of each right-hand side (only when unique; otherwise dual_one_optimal) (shadow_prices) returned by optimization-ai999x for the worked example, one value for each b (right-hand sides, one per constraint) (3 values, first 0, last 1, largest 1.5). Inputs: sense = maximize, c = 3, 5, A = 1 0; 0 2; 3 2, b = 4, 12, 18.5101500.511.5b — right-hand sides, one per constraintshadow_prices
change of the optimal value per unit increase of each right-hand side (only when unique; otherwise dual_one_optimal) (shadow_prices) returned by optimization-ai999x for the worked example, one value for each b (right-hand sides, one per constraint) (3 values, first 0, last 1, largest 1.5). Inputs: sense = maximize, c = 3, 5, A = 1 0; 0 2; 3 2, b = 4, 12, 18.
Linear program (simplex method): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); shadow_prices (returned). Returned with them by optimization-ai999x: optimal_value = 36. Other inputs: sense = maximize, c = 3, 5, b = 4, 12, 18.10023212312A (input)01.51123shadow_prices (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); shadow_prices (returned). Returned with them by optimization-ai999x: optimal_value = 36. Other inputs: sense = maximize, c = 3, 5, b = 4, 12, 18.
optimization_ai999x.solve('linear_program', sense='maximize', c='3, 5', A='1 0; 0 2; 3 2', b='4, 12, 18')
# -> optimal_value = 36, x = [2.0, 6.0], solution_unique = yes, shadow_prices = [0.0, 1.5, 1.0]   (SOLVED)
optimization_ai999x.solve('linear_program', sense='minimize', c=[2, 3], A=[[1, 1], [1, 3]], b=[4, 6], relations='>=, >=')
# -> optimal_value = 9, x = [3.0, 1.0], solution_unique = yes, shadow_prices = [1.5, 0.5]   (SOLVED)
optimization_ai999x.solve('linear_program', sense='maximize', c=[2, 4], A=[[1, 2], [1, 0]], b=[8, 5])
# -> optimal_value = 16, x_one_optimal = [5.0, 1.5], solution_unique = no, shadow_prices = [2.0, 0.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Maximize 3x + 5y subject to x <= 4, 2y <= 12, 3x + 2y <= 18, x, y >= 0.SOLVEDoptimal_value = 36, x = [2.0, 6.0], solution_unique = yes, shadow_prices = [0.0, 1.5, 1.0]
Minimize 2x1 + 3x2 subject to x1 + x2 >= 4, x1 + 3x2 >= 6, x1, x2 >= 0.SOLVEDoptimal_value = 9, x = [3.0, 1.0], solution_unique = yes, shadow_prices = [1.5, 0.5]
Maximize x + y subject to x - y >= 1, x, y >= 0.INVALID_INPUTLinear program (simplex method): the objective is unbounded on the feasible region: there is no finite optimum.
Maximize x + y subject to x + y <= 2, x + y >= 5, x, y >= 0.INVALID_INPUTLinear program (simplex method): the constraints are infeasible: no point satisfies all of them.
Maximize 3x + 5y subject to x + 2y <= 14.OUT_OF_SCOPEOut of scope: variables without a stated sign (state x >= 0 for every variable; free variables are not supported).

Two-variable linear program (graphical corner-point method) — lp_two_variable_graphical

Solve a linear program in two variables by evaluating the objective at every corner point of the feasible region.

\[z^* = \max_{v \in \text{corners}} c^\top v\]
inputmeaningcondition
sensemaximize or minimize
cobjective coefficients, one per variable
Aconstraint coefficients, one row per constraint
bright-hand sides, one per constraint
relationsrelation of each constraint: <=, >= or = (default all <=)
outputmeaning
optimal_valueoptimal value of the objective
xfirst variable at the optimum (only when the optimum is unique)
ysecond variable at the optimum (only when the optimum is unique)
optimal_cornersevery corner point at which the optimum is attained
corner_pointsevery corner point of the feasible region
solution_uniqueyes when exactly one point is optimal
A linear programme: feasible region and optimal cornerMaximise 3x + 5y subject to x ≤ 4; 2y ≤ 12; 3x + 2y ≤ 18, x, y ≥ 0: the feasible region with the corner points the package returns ((0, 0), (0, 6), (2, 6), (4, 0), (4, 3)) and the objective line through the optimum; marked: x = 2, y = 6, objective 36.02460246810optimum (2, 6)feasible regionconstraints3x + 5y = 36xy
Maximise 3x + 5y subject to x ≤ 4; 2y ≤ 12; 3x + 2y ≤ 18, x, y ≥ 0: the feasible region with the corner points the package returns ((0, 0), (0, 6), (2, 6), (4, 0), (4, 3)) and the objective line through the optimum; marked: x = 2, y = 6, objective 36.
Two-variable linear program (graphical corner-point method): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); optimal_corners (returned); corner_points (returned). Returned with them by optimization-ai999x: optimal_value = 36, x = 2, y = 6. Other inputs: sense = maximize, c = [3, 5], b = [4, 12, 18].10023212312A (input)2612optimal_corners (returned)00062640431234512corner_points (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); optimal_corners (returned); corner_points (returned). Returned with them by optimization-ai999x: optimal_value = 36, x = 2, y = 6. Other inputs: sense = maximize, c = [3, 5], b = [4, 12, 18].
optimization_ai999x.solve('lp_two_variable_graphical', sense='maximize', c=[3, 5], A=[[1, 0], [0, 2], [3, 2]], b=[4, 12, 18])
# -> optimal_value = 36, optimal_corners = [[2.0, 6.0]], corner_points = [[0.0, 0.0], [0.0, 6.0], [2.0, 6.0], [4.0, 0.0], [4.0, 3.0]], x = 2, y = 6, solution_unique = yes   (SOLVED)
optimization_ai999x.solve('lp_two_variable_graphical', sense='minimize', c=[2, 3], A=[[1, 1], [1, 3]], b=[4, 6], relations='>=,>=')
# -> optimal_value = 9, optimal_corners = [[3.0, 1.0]], corner_points = [[0.0, 4.0], [3.0, 1.0], [6.0, 0.0]], x = 3, y = 1, solution_unique = yes   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Use the graphical method to maximize 3x + 5y subject to x <= 4, 2y <= 12, 3x + 2y <= 18, x, y >= 0.SOLVEDoptimal_value = 36, optimal_corners = [[2.0, 6.0]], corner_points = [[0.0, 0.0], [0.0, 6.0], [2.0, 6.0], [4.0, 0.0], [4.0, 3.0]], x = 2, y = 6, solution_unique = yes
Graphically maximize 2x + 4y subject to x + 2y <= 8, x <= 5, x, y >= 0.SOLVEDoptimal_value = 16, optimal_corners = [[0.0, 4.0], [5.0, 1.5]], corner_points = [[0.0, 0.0], [0.0, 4.0], [5.0, 0.0], [5.0, 1.5]], solution_unique = no
Use the graphical method to maximize x + y + z subject to x + y + z <= 3, x, y, z >= 0.OUT_OF_SCOPEOut of scope: the graphical method takes exactly two variables (use the simplex method).

Integer linear program (branch and bound) — integer_program

Optimise a linear objective over non-negative INTEGER points satisfying linear constraints: the optimal value and one optimal integer solution.

\[\max / \min \; c^\top x \quad \text{s.t. } A x \;(\le,\ge,=)\; b,\; x \in \mathbb{Z}_{\ge 0}^n\]
inputmeaningcondition
sensemaximize or minimize
cobjective coefficients, one per variable
Aconstraint coefficients, one row per constraint
bright-hand sides, one per constraint
relationsrelation of each constraint: <=, >= or = (default all <=)
outputmeaning
optimal_valueoptimal value over integer points
x_one_optimalone optimal integer solution (the first found: depth-first, lowest-index fractional variable, round-down branch first)
nodesbranch-and-bound nodes explored
Integer linear program (branch and bound): the vectorsThe plane vectors of the worked example as arrows from the origin: input c = (5, 4), b = (24, 6); returned by optimization-ai999x: x_one_optimal = (4, 0); also returned optimal_value = 20, nodes = 5. Other inputs: sense = maximize, A = [[6, 4], [1, 2]]. Marked: the tip of each returned vector.01020-50510c = (5, 4) (input)b = (24, 6) (input)x_one_optimal = (4, 0) (returned)xy
The plane vectors of the worked example as arrows from the origin: input c = (5, 4), b = (24, 6); returned by optimization-ai999x: x_one_optimal = (4, 0); also returned optimal_value = 20, nodes = 5. Other inputs: sense = maximize, A = [[6, 4], [1, 2]]. Marked: the tip of each returned vector.
Integer linear program (branch and bound): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); x_one_optimal (returned). Returned with them by optimization-ai999x: optimal_value = 20, nodes = 5. Other inputs: sense = maximize, c = [5, 4], b = [24, 6].64121212A (input)4012x_one_optimal (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); x_one_optimal (returned). Returned with them by optimization-ai999x: optimal_value = 20, nodes = 5. Other inputs: sense = maximize, c = [5, 4], b = [24, 6].
optimization_ai999x.solve('integer_program', sense='maximize', c=[5, 4], A=[[6, 4], [1, 2]], b=[24, 6])
# -> optimal_value = 20, x_one_optimal = [4.0, 0.0], nodes = 5   (SOLVED)
optimization_ai999x.solve('integer_program', sense='minimize', c=[3, 2], A=[[1, 1]], b=[3.5], relations='>=')
# -> optimal_value = 8, x_one_optimal = [0.0, 4.0], nodes = 17   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Maximize 5x + 4y subject to 6x + 4y <= 24, x + 2y <= 6, x, y >= 0 and integer.SOLVEDoptimal_value = 20, x_one_optimal = [4.0, 0.0], nodes = 5
Solve the integer program: minimize 3x + 2y subject to x + y >= 3.5, x, y >= 0, integer.SOLVEDoptimal_value = 8, x_one_optimal = [0.0, 4.0], nodes = 17
Maximize x + y subject to 2x + 2y = 3, x, y >= 0, integer.INVALID_INPUTInteger linear program (branch and bound): there is no integer point satisfying all the constraints.

Shadow prices of a linear program — lp_shadow_prices

The shadow price (dual value) of each constraint: the change of the optimal value per unit increase of its right-hand side, when it is uniquely defined.

\[y^\top = c_B^\top B^{-1}, \qquad \frac{\partial z^*}{\partial b_i} = y_i\]
inputmeaningcondition
sensemaximize or minimize
cobjective coefficients, one per variable
Aconstraint coefficients, one row per constraint
bright-hand sides, one per constraint
relationsrelation of each constraint: <=, >= or = (default all <=)
outputmeaning
shadow_pricesshadow price of each constraint, in order
optimal_valueoptimal value of the objective
xthe optimal solution (only when unique; otherwise x_one_optimal)
solution_uniqueyes when the optimal solution is unique
Shadow prices of a linear program: shadow price of each constraint, in ordershadow price of each constraint, in order (shadow_prices) returned by optimization-ai999x for the worked example, one value for each b (right-hand sides, one per constraint) (3 values, first 0, last 1, largest 1.5). Inputs: sense = maximize, c = [3, 5], A = [[1, 0], [0, 2], [3, 2]], b = [4, 12, 18].5101500.511.5b — right-hand sides, one per constraintshadow_prices
shadow price of each constraint, in order (shadow_prices) returned by optimization-ai999x for the worked example, one value for each b (right-hand sides, one per constraint) (3 values, first 0, last 1, largest 1.5). Inputs: sense = maximize, c = [3, 5], A = [[1, 0], [0, 2], [3, 2]], b = [4, 12, 18].
Shadow prices of a linear program: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); shadow_prices (returned). Returned with them by optimization-ai999x: optimal_value = 36. Other inputs: sense = maximize, c = [3, 5], b = [4, 12, 18].10023212312A (input)01.51123shadow_prices (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); shadow_prices (returned). Returned with them by optimization-ai999x: optimal_value = 36. Other inputs: sense = maximize, c = [3, 5], b = [4, 12, 18].
optimization_ai999x.solve('lp_shadow_prices', sense='maximize', c=[3, 5], A=[[1, 0], [0, 2], [3, 2]], b=[4, 12, 18])
# -> optimal_value = 36, x = [2.0, 6.0], solution_unique = yes, shadow_prices = [0.0, 1.5, 1.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the shadow prices: maximize 3x + 5y subject to x <= 4, 2y <= 12, 3x + 2y <= 18, x, y >= 0.SOLVEDoptimal_value = 36, x = [2.0, 6.0], solution_unique = yes, shadow_prices = [0.0, 1.5, 1.0]
What are the dual values when you minimize 2x + 3y subject to x + y >= 4, x + 3y >= 6, x, y >= 0?SOLVEDoptimal_value = 9, x = [3.0, 1.0], solution_unique = yes, shadow_prices = [1.5, 0.5]

Optimum of a quadratic function — quadratic_optimum

The minimum or maximum of f(x) = a $x^{2} + b$ x + c: where it occurs and its value.

\[x^* = -\frac{b}{2a}, \quad f^* = c - \frac{b^2}{4a}\]
inputmeaningcondition
acoefficient of $x^{2}$
bcoefficient of x
cconstant term
goalminimum, maximum or optimum (default optimum)
outputmeaning
x_optx at the optimum
f_optoptimal value f(x*)
typeminimum $(a > 0)$ or maximum $(a < 0)$
Optimum of a quadratic function: optimal value f(x*) against coefficient of x^2f_opt (optimal value f(x*)) against a (coefficient of x^2) from 0.2 to 20 on a logarithmic axis. One curve for each value of c (constant term): 3, 6. Other inputs as in the worked example: b = -8. 41 points per curve computed by optimization-ai999x; marked: the worked example, a = 2, f_opt = -5.110-80-60-40-200-5c = 3 (example)c = 6a — coefficient of x^2f_opt — optimal value f(x*)
f_opt (optimal value f(x*)) against a (coefficient of x^2) from 0.2 to 20 on a logarithmic axis. One curve for each value of c (constant term): 3, 6. Other inputs as in the worked example: b = -8. 41 points per curve computed by optimization-ai999x; marked: the worked example, a = 2, f_opt = -5.
optimization_ai999x.solve('quadratic_optimum', a=2, b=-8, c=3)
# -> x_opt = 2, f_opt = -5, type = minimum   (SOLVED)
optimization_ai999x.solve('quadratic_optimum', a=-1, b=6, c=1)
# -> x_opt = 3, f_opt = 10, type = maximum   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the minimum of f(x) = 2x^2 - 8x + 3.SOLVEDx_opt = 2, f_opt = -5, type = minimum
What is the maximum value of y = -x^2 + 6x + 1?SOLVEDx_opt = 3, f_opt = 10, type = maximum
Find the minimum of f(x) = -x^2 + 4x.INVALID_INPUTOptimum of a quadratic function: with a < 0 the parabola opens downward: it has a maximum, no minimum.

Break-even quantity — break_even_point

The number of units at which revenue equals total cost (fixed plus variable), and the revenue there.

\[Q_{BE} = \frac{F}{p - v}\]
inputmeaningcondition
F_fixed cost (currency)
pselling price per unit
vvariable cost per unit
outputmeaning
quantitybreak-even quantity (units)
revenuerevenue at break-even
contribution_marginprice minus variable cost per unit
Break-even quantity: break-even quantity (units) against selling price per unitquantity (break-even quantity (units)) against p (selling price per unit) from 12.5 to 37.5. One curve for each value of F_ (fixed cost (currency)): 5000, 2500, 10000. Other inputs as in the worked example: v = 15. 27 points per curve computed by optimization-ai999x; marked: the worked example, p = 25, quantity = 500.15202530350500010000500F_ = 5000 (example)F_ = 2500F_ = 10000p — selling price per unitquantity — break-even quantity (units)
quantity (break-even quantity (units)) against p (selling price per unit) from 12.5 to 37.5. One curve for each value of F_ (fixed cost (currency)): 5000, 2500, 10000. Other inputs as in the worked example: v = 15. 27 points per curve computed by optimization-ai999x; marked: the worked example, p = 25, quantity = 500.
optimization_ai999x.solve('break_even_point', F_=5000, p=25, v=15)
# -> quantity = 500, revenue = 12500, contribution_margin = 10   (SOLVED)
optimization_ai999x.solve('break_even_point', F_=1200, p=7.5, v=4.5)
# -> quantity = 400, revenue = 3000, contribution_margin = 3   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
A firm has fixed costs of 5000, a selling price of 25 per unit and a variable cost of 15 per unit. Find the break-even quantity.SOLVEDquantity = 500, revenue = 12500, contribution_margin = 10
Find the break-even point if fixed costs are 1200, the price is 7.5 and the variable cost is 4.5 per unit.SOLVEDquantity = 400, revenue = 3000, contribution_margin = 3
Find the break-even point if fixed costs are 1200, the price is 4 and the variable cost is 4.5 per unit.INVALID_INPUTBreak-even quantity: the price must exceed the variable cost per unit, otherwise no break-even point exists.
Find the break-even quantity with fixed costs of 1200 and a price of 7.5.NEEDS_INPUTbreak_even_point needs v (variable cost per unit). Example: solve('break_even_point', F_=5000, p=25, v=15).

Profit-maximising output with linear demand — profit_max_linear_demand

With inverse demand $p = a - b$ q and cost $C = F + c$ q, the output, price and profit at the profit maximum.

\[q^* = \frac{a - c}{2b}, \quad p^* = \frac{a + c}{2}\]
inputmeaningcondition
ademand intercept (price at zero quantity)
bdemand slope (price drop per unit)
cvmarginal (variable) cost per unit
F_fixed cost (default 0)
outputmeaning
quantityprofit-maximising quantity
priceprice at that quantity
profitmaximum profit
Profit-maximising output with linear demand: profit-maximising quantity against demand slope (price drop pe…quantity (profit-maximising quantity) against b (demand slope (price drop per unit)) from 1 to 3. One curve for each value of a (demand intercept (price at zero quantity)): 100, 50, 200. Other inputs as in the worked example: cv = 20, F_ = 300. 31 points per curve computed by optimization-ai999x; marked: the worked example, b = 2, quantity = 20.11.522.5302040608020a = 100 (example)a = 50a = 200b — demand slope (price drop per unit)quantity — profit-maximising quantity
quantity (profit-maximising quantity) against b (demand slope (price drop per unit)) from 1 to 3. One curve for each value of a (demand intercept (price at zero quantity)): 100, 50, 200. Other inputs as in the worked example: cv = 20, F_ = 300. 31 points per curve computed by optimization-ai999x; marked: the worked example, b = 2, quantity = 20.
optimization_ai999x.solve('profit_max_linear_demand', a=100, b=2, cv=20, F_=300)
# -> quantity = 20, price = 60, profit = 500   (SOLVED)
optimization_ai999x.solve('profit_max_linear_demand', a=50, b=0.5, cv=10)
# -> quantity = 40, price = 30, profit = 800   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
The demand is p = 100 - 2q and the cost is C = 300 + 20q. Find the profit-maximizing quantity.SOLVEDquantity = 20, price = 60, profit = 500
With demand p = 50 - 0.5q and cost C = 10q + 0, what output maximizes profit?SOLVEDquantity = 40, price = 30, profit = 800
With demand p = 10 - 2q and cost C = 100 + 20q, what output maximizes profit?INVALID_INPUTProfit-maximising output with linear demand: the demand intercept must exceed the marginal cost, otherwise no positive o

Revenue-maximising price with linear demand — revenue_max_linear_demand

With demand $q = \alpha - \beta$ p, the price that maximises revenue p q, the quantity sold and the revenue.

\[p^* = \frac{\alpha}{2\beta}, \quad R^* = \frac{\alpha^2}{4\beta}\]
inputmeaningcondition
alphademand at a price of zero
betadrop in demand per unit increase in price
outputmeaning
pricerevenue-maximising price
quantityquantity sold at that price
revenuemaximum revenue
Revenue-maximising price with linear demand: revenue-maximising price against drop in demand per unit incre…price (revenue-maximising price) against beta (drop in demand per unit increase in price) from 10 to 30. One curve for each value of alpha (demand at a price of zero): 1000, 500, 2000. 31 points per curve computed by optimization-ai999x; marked: the worked example, beta = 20, price = 25.101520253025507510025alpha = 1000 (example)alpha = 500alpha = 2000betaprice — revenue-maximising price
price (revenue-maximising price) against beta (drop in demand per unit increase in price) from 10 to 30. One curve for each value of alpha (demand at a price of zero): 1000, 500, 2000. 31 points per curve computed by optimization-ai999x; marked: the worked example, beta = 20, price = 25.
Revenue-maximising price with linear demand: revenue-maximising price over demand at a price of zero and dr…price (revenue-maximising price) over alpha (demand at a price of zero) from 500 to 1500 and beta (drop in demand per unit increase in price) from 10 to 30: each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 8.33333 to dark 75); iso-lines at price = 20, 40, 60. Marked: the worked example, alpha = 1000, beta = 20, price = 25.500750100012501500101520253020406025758.33333pricealpha — demand at a price of zerobeta
price (revenue-maximising price) over alpha (demand at a price of zero) from 500 to 1500 and beta (drop in demand per unit increase in price) from 10 to 30: each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 8.33333 to dark 75); iso-lines at price = 20, 40, 60. Marked: the worked example, alpha = 1000, beta = 20, price = 25.
optimization_ai999x.solve('revenue_max_linear_demand', alpha=1000, beta=20)
# -> price = 25, quantity = 500, revenue = 12500   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
The demand is q = 1000 - 20p. Find the revenue-maximizing price.SOLVEDprice = 25, quantity = 500, revenue = 12500
If demand is q = 600 - 3p, what price maximizes revenue?SOLVEDprice = 100, quantity = 300, revenue = 30000

Largest rectangle for a given length of fencing — fence_max_area

The dimensions and maximum area of a rectangle enclosed by a fence of length L, on four sides or on three sides with a wall or river as the fourth.

\[A_{\max} = \frac{L^2}{16} \text{ (4 sides)}, \quad \frac{L^2}{8} \text{ (3 sides)}\]
inputmeaningcondition
Ltotal length of fencing (any length unit)
walltrue when one side lies along a wall or river and needs no fence
outputmeaning
widthside perpendicular to the wall (or one side of the square)
lengthside parallel to the wall
max_areamaximum enclosed area (square of the length unit)
Largest rectangle for a given length of fencing: maximum enclosed area (square of the length unit) against…max_area (maximum enclosed area (square of the length unit)) against L (total length of fencing (any length unit)) from 100 to 300. One curve for each value of wall (true when one side lies along a wall or river and needs no fence): None, yes. 31 points per curve computed by optimization-ai999x; marked: the worked example, L = 200, max_area = 2500.1001502002503000250050007500100002500wall = None (example)wall = yesL — total length of fencingmax_area — maximum enclosed area
max_area (maximum enclosed area (square of the length unit)) against L (total length of fencing (any length unit)) from 100 to 300. One curve for each value of wall (true when one side lies along a wall or river and needs no fence): None, yes. 31 points per curve computed by optimization-ai999x; marked: the worked example, L = 200, max_area = 2500.
optimization_ai999x.solve('fence_max_area', L=200)
# -> width = 50, length = 50, max_area = 2500   (SOLVED)
optimization_ai999x.solve('fence_max_area', L=200, wall=True)
# -> width = 50, length = 100, max_area = 5000   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
A farmer has 200 m of fencing to enclose a rectangular field. What is the maximum area?SOLVEDwidth = 50, length = 50, max_area = 2500
A farmer has 200 m of fencing to enclose a rectangular field along a river, with no fence along the river. Find the maximum area.SOLVEDwidth = 50, length = 100, max_area = 5000
A farmer has 200 m of fencing to enclose a rectangular field on all four sides, with no wall or river to use as a boundary. What is the maximum area?SOLVEDwidth = 50, length = 50, max_area = 2500
A farmer has 200 m of fencing to enclose a rectangular field along a river, fencing all four sides. What is the maximum area?UNRECOGNIZED_FORMATI could not match this question to a documented form, so I will not guess. Every form: optimization_ai999x.templates();
What is the largest area of a rectangular pen made with fencing?NEEDS_INPUTfence_max_area needs L (total length of fencing (any length unit)). Example: solve('fence_max_area', L=200).

Open box of maximum volume from a rectangular sheet — open_box_max_volume

Squares of side x are cut from the corners of an L by W sheet and the sides folded up: the cut that maximises the volume, and that volume.

\[x^* = \frac{(L+W) - \sqrt{L^2 - LW + W^2}}{6}\]
inputmeaningcondition
Lsheet length
Wsheet width
outputmeaning
cutside of the corner squares at the maximum
max_volumemaximum volume
Open box of maximum volume from a rectangular sheet: maximum volume against sheet lengthmax_volume (maximum volume) against L (sheet length) from 1.2 to 120 on a logarithmic axis. One curve for each value of W (sheet width): 12, 6, 24. 41 points per curve computed by optimization-ai999x; marked: the worked example, L = 12, max_volume = 128.11010002000400060008000128W = 12 (example)W = 6W = 24L — sheet lengthmax_volume — maximum volume
max_volume (maximum volume) against L (sheet length) from 1.2 to 120 on a logarithmic axis. One curve for each value of W (sheet width): 12, 6, 24. 41 points per curve computed by optimization-ai999x; marked: the worked example, L = 12, max_volume = 128.
Open box of maximum volume from a rectangular sheet: maximum volume over sheet length and sheet widthmax_volume (maximum volume) over L (sheet length) from 1.2 to 120 and W (sheet width) from 1.2 to 120 (logarithmic axes): each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 0.128 to dark 128000, logarithmic shading); iso-lines at max_volume = 1, 10, 100, 1000, 10000. Marked: the worked example, L = 12, W = 12, max_volume = 128.10100101001101001000100001281.28e50.128max_volumeL — sheet lengthW — sheet width
max_volume (maximum volume) over L (sheet length) from 1.2 to 120 and W (sheet width) from 1.2 to 120 (logarithmic axes): each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 0.128 to dark 128000, logarithmic shading); iso-lines at max_volume = 1, 10, 100, 1000, 10000. Marked: the worked example, L = 12, W = 12, max_volume = 128.
optimization_ai999x.solve('open_box_max_volume', L=12, W=12)
# -> cut = 2, max_volume = 128   (SOLVED)
optimization_ai999x.solve('open_box_max_volume', L=8, W=5)
# -> cut = 1, max_volume = 18   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
An open box is made from a 12 by 12 sheet by cutting equal squares from the corners. Find the maximum volume.SOLVEDcut = 2, max_volume = 128
Squares are cut from the corners of an 8 cm by 5 cm card to make an open box. What cut gives the largest volume?SOLVEDcut = 1, max_volume = 18

Closed cylinder of least surface area for a given volume — can_min_surface

The radius, height and surface area of the closed cylindrical can that holds a volume V with the least material.

\[r^* = \left(\frac{V}{2\pi}\right)^{1/3}, \quad h^* = 2r^*\]
inputmeaningcondition
Vvolume (cube of the length unit)
outputmeaning
radiusoptimal radius
heightoptimal height (equal to the diameter)
min_arealeast total surface area
Closed cylinder of least surface area for a given volume: least total surface area against volume (cube of…min_area (least total surface area) against V (volume (cube of the length unit)) from 3.14159 to 9.42478. 31 points computed by optimization-ai999x; marked: the worked example, V = 6.28319, min_area = 18.8496.46815202518.8496V — volume (cube of the length unit)min_area — least total surface area
min_area (least total surface area) against V (volume (cube of the length unit)) from 3.14159 to 9.42478. 31 points computed by optimization-ai999x; marked: the worked example, V = 6.28319, min_area = 18.8496.
optimization_ai999x.solve('can_min_surface', V=6.283185307179586)
# -> radius = 1, height = 2, min_area = 18.8496   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
A closed cylindrical can must hold 500 cm^3. Find the dimensions that minimize the surface area.SOLVEDradius = 4.30127, height = 8.60254, min_area = 348.734
An open cylindrical tank must hold 10 m^3. Find the radius that minimizes the surface area.OUT_OF_SCOPEOut of scope: an open cylinder (this capability is the closed can).

Economic order quantity (EOQ) — eoq

The order size that minimises ordering plus holding cost for a steady demand, the minimum cost, the number of orders per period and the time between orders.

\[Q^* = \sqrt{\frac{2 D S}{H}}, \quad TC^* = \sqrt{2 D S H}\]
inputmeaningcondition
Ddemand per period (units, e.g. per year)
Sfixed cost per order
Hholding cost per unit per period
outputmeaning
Qeconomic order quantity
total_costminimum ordering + holding cost per period
orders_per_periodnumber of orders per period
cycle_timetime between orders (in periods)
Economic order quantity (EOQ): economic order quantity against holding cost per unit per periodQ (economic order quantity) against H (holding cost per unit per period) from 1.5 to 4.5. One curve for each value of D (demand per period (units, e.g. per year)): 1200, 600, 2400. Other inputs as in the worked example: S = 50. 31 points per curve computed by optimization-ai999x; marked: the worked example, H = 3, Q = 200.234100200300400200D = 1200 (example)D = 600D = 2400H — holding cost per unit per periodQ — economic order quantity
Q (economic order quantity) against H (holding cost per unit per period) from 1.5 to 4.5. One curve for each value of D (demand per period (units, e.g. per year)): 1200, 600, 2400. Other inputs as in the worked example: S = 50. 31 points per curve computed by optimization-ai999x; marked: the worked example, H = 3, Q = 200.
optimization_ai999x.solve('eoq', D=1200, S=50, H=3)
# -> Q = 200, total_cost = 600, orders_per_period = 6, cycle_time = 0.166667   (SOLVED)
optimization_ai999x.solve('eoq', D=1000, S=10, H=0.5)
# -> Q = 200, total_cost = 100, orders_per_period = 5, cycle_time = 0.2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the EOQ for an annual demand of 1200 units, an ordering cost of 50 per order and a holding cost of 3 per unit per year.SOLVEDQ = 200, total_cost = 600, orders_per_period = 6, cycle_time = 0.166667
What is the economic order quantity if demand is 1000 units per year, the setup cost is 10 and the holding cost is 0.5 per unit per year?SOLVEDQ = 200, total_cost = 100, orders_per_period = 5, cycle_time = 0.2
Find the EOQ for an annual demand of 1200 units and an ordering cost of 50 per order.NEEDS_INPUTeoq needs H (holding cost per unit per period). Example: solve('eoq', D=1200, S=50, H=3).

EOQ with planned backorders — eoq_planned_shortages

The order quantity and the planned maximum backorder that minimise ordering, holding and shortage cost when unmet demand is backordered.

\[Q^* = \sqrt{\frac{2DS}{H}\cdot\frac{H+B}{B}}, \quad s^* = Q^* \frac{H}{H+B}\]
inputmeaningcondition
Ddemand per period
Scost per order
Hholding cost per unit per period
Bbackorder (shortage) cost per unit per period
outputmeaning
Qoptimal order quantity
max_backorderplanned maximum backorder
max_inventorymaximum inventory level
total_costminimum total cost per period
EOQ with planned backorders: optimal order quantity against holding cost per unit per periodQ (optimal order quantity) against H (holding cost per unit per period) from 0.3 to 30 on a logarithmic axis. One curve for each value of D (demand per period): 1200, 600, 2400. Other inputs as in the worked example: S = 50, B = 6. 41 points per curve computed by optimization-ai999x; marked: the worked example, H = 3, Q = 244.949.110200400600800244.949D = 1200 (example)D = 600D = 2400H — holding cost per unit per periodQ — optimal order quantity
Q (optimal order quantity) against H (holding cost per unit per period) from 0.3 to 30 on a logarithmic axis. One curve for each value of D (demand per period): 1200, 600, 2400. Other inputs as in the worked example: S = 50, B = 6. 41 points per curve computed by optimization-ai999x; marked: the worked example, H = 3, Q = 244.949.
optimization_ai999x.solve('eoq_planned_shortages', D=1200, S=50, H=3, B=6)
# -> Q = 244.949, max_backorder = 81.6497, max_inventory = 163.299, total_cost = 489.898   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the EOQ with backorders for an annual demand of 1200 units, an ordering cost of 50, a holding cost of 3 and a shortage cost of 6 per unit per year.SOLVEDQ = 244.949, max_backorder = 81.6497, max_inventory = 163.299, total_cost = 489.898

Economic production quantity (EPQ) — epq_production_lot

The production lot size that minimises setup plus holding cost when stock builds up gradually at a finite production rate.

\[Q^* = \sqrt{\frac{2DS}{H(1 - D/P)}}\]
inputmeaningcondition
Ddemand rate per period
Pproduction rate per period (> D)
Ssetup cost per run
Hholding cost per unit per period
outputmeaning
Qeconomic production quantity
max_inventorymaximum inventory Q $(1 - D/P)$
total_costminimum setup + holding cost per period
runs_per_periodproduction runs per period
Economic production quantity (EPQ): economic production quantity against production rate per period (> D)Q (economic production quantity) against P (production rate per period (> D)) from 1000 to 3000. One curve for each value of S (setup cost per run): 100, 50, 200. Other inputs as in the worked example: D = 1000, H = 4. 30 points per curve computed by optimization-ai999x; marked: the worked example, P = 2000, Q = 316.228.1000150020002500300025050075010001250316.228S = 100 (example)S = 50S = 200P — production rate per period (> D)Q — economic production quantity
Q (economic production quantity) against P (production rate per period (> D)) from 1000 to 3000. One curve for each value of S (setup cost per run): 100, 50, 200. Other inputs as in the worked example: D = 1000, H = 4. 30 points per curve computed by optimization-ai999x; marked: the worked example, P = 2000, Q = 316.228.
optimization_ai999x.solve('epq_production_lot', D=1000, P=2000, S=100, H=4)
# -> Q = 316.228, max_inventory = 158.114, total_cost = 632.456, runs_per_period = 3.16228   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the EPQ for an annual demand of 1000 units, a production rate of 2000 units per year, a setup cost of 100 and a holding cost of 4 per unit per year.SOLVEDQ = 316.228, max_inventory = 158.114, total_cost = 632.456, runs_per_period = 3.16228
Find the economic production quantity for a demand of 3000 units, a production rate of 2000 units, a setup cost of 100 and a holding cost of 4.INVALID_INPUTEconomic production quantity (EPQ): the production rate must exceed the demand rate.

Order quantity with quantity discounts (all-units) — eoq_quantity_discount

With all-units price breaks, the order quantity that minimises purchase + ordering + holding cost, the price paid and the minimum total cost per period.

\[TC(Q) = D p_k + \frac{D S}{Q} + \frac{i p_k Q}{2}\]
inputmeaningcondition
Ddemand per period
Scost per order
i_rateholding cost as a fraction of the unit price per period (0.2 = 20%)
breaksminimum order quantity of each price tier, increasing, the first 0
pricesunit price of each tier
outputmeaning
order_quantityoptimal order quantity
total_costminimum total cost per period (purchase + ordering + holding)
unit_priceunit price paid
Order quantity with quantity discounts (all-units): minimum total cost per period (purchase + ordering + ho…total_cost (minimum total cost per period (purchase + ordering + holding)) against D (demand per period) from 2500 to 7500. One curve for each value of i_rate (holding cost as a fraction of the unit price per period (0.2 = 20%)): 0.2, 0.74. Other inputs as in the worked example: S = 49, breaks = 0, 1000, 2000, prices = 5, 4.8, 4.75. 31 points per curve computed by optimization-ai999x; marked: the worked example, D = 5000, total_cost = 24725.4000600020000300004000024725i_rate = 0.2 (example)i_rate = 0.74D — demand per periodtotal_cost — minimum total cost per period
total_cost (minimum total cost per period (purchase + ordering + holding)) against D (demand per period) from 2500 to 7500. One curve for each value of i_rate (holding cost as a fraction of the unit price per period (0.2 = 20%)): 0.2, 0.74. Other inputs as in the worked example: S = 49, breaks = 0, 1000, 2000, prices = 5, 4.8, 4.75. 31 points per curve computed by optimization-ai999x; marked: the worked example, D = 5000, total_cost = 24725.
optimization_ai999x.solve('eoq_quantity_discount', D=5000, S=49, i_rate=0.2, breaks='0, 1000, 2000', prices='5, 4.8, 4.75')
# -> order_quantity = 1000, total_cost = 24725, unit_price = 4.8   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Quantity discounts: annual demand 5000, ordering cost 49, holding rate 20%, price breaks at [0, 1000, 2000] with prices [5, 4.8, 4.75]. Find the best order quantity.SOLVEDorder_quantity = 1000, total_cost = 24725, unit_price = 4.8

Reorder point with safety stock — reorder_point

The stock level at which to reorder so that demand during the lead time is covered with a given cycle service level, for normally distributed demand per period.

\[ROP = \bar d L + z_{SL}\,\sigma_d \sqrt{L}\]
inputmeaningcondition
daverage demand per period
Llead time in periods
sigmastandard deviation of demand per period
SLcycle service level (probability of no stockout per cycle, e.g. 0.95)
outputmeaning
reorder_pointreorder point
safety_stocksafety stock z sigma sqrt(L)
zstandard normal quantile of the service level
lead_time_demandexpected demand during the lead time
Reorder point with safety stock: reorder point against cycle service level (probability of no stockout per…reorder_point (reorder point) against SL (cycle service level (probability of no stockout per cycle, e.g. 0.95)) from 0.475 to 0.999. One curve for each value of L (lead time in periods): 9, 4.5, 18. Other inputs as in the worked example: d = 40, sigma = 8. 29 points per curve computed by optimization-ai999x; marked: the worked example, SL = 0.95, reorder_point = 399.476.0.60.81200400600800399.476L = 9 (example)L = 4.5L = 18SL — cycle service levelreorder_point — reorder point
reorder_point (reorder point) against SL (cycle service level (probability of no stockout per cycle, e.g. 0.95)) from 0.475 to 0.999. One curve for each value of L (lead time in periods): 9, 4.5, 18. Other inputs as in the worked example: d = 40, sigma = 8. 29 points per curve computed by optimization-ai999x; marked: the worked example, SL = 0.95, reorder_point = 399.476.
optimization_ai999x.solve('reorder_point', d=40, L=9, sigma=8, SL=0.95)
# -> reorder_point = 399.476, safety_stock = 39.4765, z = 1.64485, lead_time_demand = 360   (SOLVED)
optimization_ai999x.solve('reorder_point', d=100, L=4, sigma=0, SL=0.9)
# -> reorder_point = 400, safety_stock = 0, z = 1.28155, lead_time_demand = 400   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Daily demand averages 40 units with a standard deviation of 8 units, the lead time is 9 days and the service level is 95%. Find the reorder point.SOLVEDreorder_point = 399.476, safety_stock = 39.4765, z = 1.64485, lead_time_demand = 360
Find the reorder point with demand of 40 per day, standard deviation 8, lead time 9 days and service level 120%.INVALID_INPUTReorder point with safety stock: the service level must be at least 0.5 and below 1 (e.g. 0.95).

Periodic-review order-up-to level — order_up_to_level

The target inventory position S of a periodic-review system that covers demand over the review period plus the lead time with a given cycle service level.

\[S = \bar d (R + L) + z_{SL}\,\sigma_d\sqrt{R + L}\]
inputmeaningcondition
daverage demand per period
sigmastandard deviation of demand per period
Rreview period (periods)
Llead time (periods)
SLcycle service level, e.g. 0.95
outputmeaning
order_up_to_levelorder-up-to level S
safety_stocksafety stock z sigma sqrt(R + L)
zstandard normal quantile
Periodic-review order-up-to level: order-up-to level S against average demand per periodorder_up_to_level (order-up-to level S) against d (average demand per period) from 10 to 30. One curve for each value of R (review period (periods)): 7, 3.5, 14. Other inputs as in the worked example: sigma = 4, L = 2, SL = 0.95. 31 points per curve computed by optimization-ai999x; marked: the worked example, d = 20, order_up_to_level = 199.738.1015202530200400199.738R = 7 (example)R = 3.5R = 14d — average demand per periodorder_up_to_level — order-up-to level S
order_up_to_level (order-up-to level S) against d (average demand per period) from 10 to 30. One curve for each value of R (review period (periods)): 7, 3.5, 14. Other inputs as in the worked example: sigma = 4, L = 2, SL = 0.95. 31 points per curve computed by optimization-ai999x; marked: the worked example, d = 20, order_up_to_level = 199.738.
optimization_ai999x.solve('order_up_to_level', d=20, sigma=4, R=7, L=2, SL=0.95)
# -> order_up_to_level = 199.738, safety_stock = 19.7382, z = 1.64485   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
In a periodic review system, demand averages 20 units per day with a standard deviation of 4, the review period is 7 days, the lead time is 2 days and the service level is 95%. Find the order-up-to level.SOLVEDorder_up_to_level = 199.738, safety_stock = 19.7382, z = 1.64485

Newsvendor order quantity (normal demand) — newsvendor_normal

The single-period order quantity that maximises expected profit for normally distributed demand: the critical ratio, the optimal quantity and the expected profit.

\[F(Q^*) = \frac{p - c}{p - s}, \quad Q^* = \mu + z\,\sigma\]
inputmeaningcondition
pselling price per unit
ccost per unit
mumean demand
sigmastandard deviation of demand
ssalvage value per unsold unit (default 0)
outputmeaning
critical_ratiocritical ratio (p - c)/(p - s)
Qoptimal order quantity
expected_profitexpected profit at Q
expected_shortageexpected unmet demand at Q
Newsvendor order quantity (normal demand): optimal order quantity against selling price per unitQ (optimal order quantity) against p (selling price per unit) from 0.2 to 20 on a logarithmic axis. One curve for each value of mu (mean demand): 100, 50, 200. Other inputs as in the worked example: c = 0.5, sigma = 20, s = 0.2. 33 points per curve computed by optimization-ai999x; marked: the worked example, p = 2, Q = 119.348.1100100200119.348mu = 100 (example)mu = 50mu = 200p — selling price per unitQ — optimal order quantity
Q (optimal order quantity) against p (selling price per unit) from 0.2 to 20 on a logarithmic axis. One curve for each value of mu (mean demand): 100, 50, 200. Other inputs as in the worked example: c = 0.5, sigma = 20, s = 0.2. 33 points per curve computed by optimization-ai999x; marked: the worked example, p = 2, Q = 119.348.
optimization_ai999x.solve('newsvendor_normal', p=2, c=0.5, s=0.2, mu=100, sigma=20)
# -> critical_ratio = 0.833333, Q = 119.348, expected_profit = 141.005, expected_shortage = 1.77228   (SOLVED)
optimization_ai999x.solve('newsvendor_normal', p=10, c=5, mu=500, sigma=50)
# -> critical_ratio = 0.5, Q = 500, expected_profit = 2300.53, expected_shortage = 19.9471   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Newsvendor problem: a paper sells for 2 and costs 0.5, leftovers are sold for salvage of 0.2, and demand is normal with mean 100 and standard deviation 20. Find the optimal order quantity.SOLVEDcritical_ratio = 0.833333, Q = 119.348, expected_profit = 141.005, expected_shortage = 1.77228
Newsvendor: price 5, cost 6, demand normal with mean 100 and standard deviation 20. Find the order quantity.INVALID_INPUTNewsvendor order quantity (normal demand): the salvage value, unit cost and price must satisfy salvage < cost < price.

Newsvendor order quantity (uniform demand) — newsvendor_uniform

The single-period order quantity that maximises expected profit when demand is uniform on [a, b].

\[Q^* = a + \frac{p - c}{p - s}(b - a)\]
inputmeaningcondition
pselling price per unit
ccost per unit
lolowest possible demand a
hihighest possible demand b
ssalvage value per unsold unit (default 0)
outputmeaning
critical_ratiocritical ratio (p - c)/(p - s)
Qoptimal order quantity a + CR (b - a)
expected_profitexpected profit at Q
Newsvendor order quantity (uniform demand): expected profit at Q against selling price per unitexpected_profit (expected profit at Q) against p (selling price per unit) from 5 to 15. One curve for each value of hi (highest possible demand b): 300, 150, 600. Other inputs as in the worked example: c = 4, lo = 100. 31 points per curve computed by optimization-ai999x; marked: the worked example, p = 10, expected_profit = 960.57.51012.5150100020003000960hi = 300 (example)hi = 150hi = 600p — selling price per unitexpected_profit — expected profit at Q
expected_profit (expected profit at Q) against p (selling price per unit) from 5 to 15. One curve for each value of hi (highest possible demand b): 300, 150, 600. Other inputs as in the worked example: c = 4, lo = 100. 31 points per curve computed by optimization-ai999x; marked: the worked example, p = 10, expected_profit = 960.
optimization_ai999x.solve('newsvendor_uniform', p=10, c=4, lo=100, hi=300)
# -> critical_ratio = 0.6, Q = 220, expected_profit = 960   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Newsvendor: an item sells for 10 and costs 4, with uniform demand between 100 and 300. Find the optimal order quantity.SOLVEDcritical_ratio = 0.6, Q = 220, expected_profit = 960

Newsvendor order quantity (discrete demand) — newsvendor_discrete

For demand taking listed values with given probabilities, the order quantity that maximises expected profit (the smallest demand value whose cumulative probability reaches the critical ratio) and that profit.

\[Q^* = \min\{ d : F(d) \ge \tfrac{p - c}{p - s} \}\]
inputmeaningcondition
pselling price per unit
ccost per unit
demandspossible demand values, increasing
probsprobability of each demand value (sum 1)
ssalvage value per unsold unit (default 0)
outputmeaning
critical_ratiocritical ratio (p - c)/(p - s)
Qoptimal order quantity (smallest optimal value)
expected_profitmaximum expected profit
Newsvendor order quantity (discrete demand): maximum expected profit against selling price per unitexpected_profit (maximum expected profit) against p (selling price per unit) from 5 to 15. One curve for each value of c (cost per unit): 4, 2, 8. Other inputs as in the worked example: demands = 10, 20, 30, 40, probs = 0.1, 0.3, 0.4, 0.2. 31 points per curve computed by optimization-ai999x; marked: the worked example, p = 10, expected_profit = 130.57.51012.5150100200300130c = 4 (example)c = 2c = 8p — selling price per unitexpected_profit — maximum expected profit
expected_profit (maximum expected profit) against p (selling price per unit) from 5 to 15. One curve for each value of c (cost per unit): 4, 2, 8. Other inputs as in the worked example: demands = 10, 20, 30, 40, probs = 0.1, 0.3, 0.4, 0.2. 31 points per curve computed by optimization-ai999x; marked: the worked example, p = 10, expected_profit = 130.
Newsvendor order quantity (discrete demand): maximum expected profit over selling price per unit and cost p…expected_profit (maximum expected profit) over p (selling price per unit) from 5 to 15 and c (cost per unit) from 2 to 6: each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 0.714286 to dark 325); iso-lines at expected_profit = 100, 200, 300; blank cells: inputs the capability refuses. Other inputs as in the worked example: demands = 10, 20, 30, 40, probs = 0.1, 0.3, 0.4, 0.2. Marked: the worked example, p = 10, c = 4, expected_profit = 130.57.51012.515234561002003001303250.714286expected_pp — selling price per unitc — cost per unit
expected_profit (maximum expected profit) over p (selling price per unit) from 5 to 15 and c (cost per unit) from 2 to 6: each of the 21 × 15 cells is one run of optimization-ai999x, shaded by its value (light 0.714286 to dark 325); iso-lines at expected_profit = 100, 200, 300; blank cells: inputs the capability refuses. Other inputs as in the worked example: demands = 10, 20, 30, 40, probs = 0.1, 0.3, 0.4, 0.2. Marked: the worked example, p = 10, c = 4, expected_profit = 130.
optimization_ai999x.solve('newsvendor_discrete', p=10, c=4, demands='10, 20, 30, 40', probs='0.1, 0.3, 0.4, 0.2')
# -> critical_ratio = 0.6, Q = 30, expected_profit = 130   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Newsvendor: a cake sells for 10 and costs 4; demand values [10, 20, 30, 40] have probabilities [0.1, 0.3, 0.4, 0.2]. How many should be ordered?SOLVEDcritical_ratio = 0.6, Q = 30, expected_profit = 130
Newsvendor: a cake sells for 10 and costs 4; demand values [10, 20, 30, 40] have probabilities [0.1, 0.3, 0.4, 0.4]. How many should be ordered?INVALID_INPUTNewsvendor order quantity (discrete demand): the probabilities must be >= 0 and sum to 1.

Littlewood's rule (two-fare protection level) — littlewood_protection

How many seats (units) to protect for full-fare demand when a discount fare is also sold: the protection level and, with a capacity, the booking limit for the discount class.

\[P(D_1 > y^*) = \frac{p_2}{p_1}, \quad y^* = \mu + z\,\sigma\]
inputmeaningcondition
p1full fare
p2discount fare
mumean full-fare demand
sigmastandard deviation of full-fare demand
capacitytotal capacity (optional)
outputmeaning
protection_levelunits protected for full-fare demand
zstandard normal quantile of $1 - p_{2}/p_{1}$
booking_limitdiscount booking limit = capacity - protection (when a capacity is given)
Littlewood's rule (two-fare protection level): units protected for full-fare demand against full fareprotection_level (units protected for full-fare demand) against p1 (full fare) from 200 to 600. One curve for each value of mu (mean full-fare demand): 60, 30, 120. Other inputs as in the worked example: p2 = 150, sigma = 20. 31 points per curve computed by optimization-ai999x; marked: the worked example, p1 = 400, protection_level = 66.3728.2003004005006005010066.3728mu = 60 (example)mu = 30mu = 120p1 — full fareprotection_level
protection_level (units protected for full-fare demand) against p1 (full fare) from 200 to 600. One curve for each value of mu (mean full-fare demand): 60, 30, 120. Other inputs as in the worked example: p2 = 150, sigma = 20. 31 points per curve computed by optimization-ai999x; marked: the worked example, p1 = 400, protection_level = 66.3728.
optimization_ai999x.solve('littlewood_protection', p1=400, p2=150, mu=60, sigma=20)
# -> protection_level = 66.3728, z = 0.318639   (SOLVED)
optimization_ai999x.solve('littlewood_protection', p1=200, p2=100, mu=50, sigma=10, capacity=120)
# -> protection_level = 50, z = 0, booking_limit = 70   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Littlewood's rule: the full fare is 400 and the discount fare is 150; full-fare demand has mean 60 and standard deviation 20. Find the protection level.SOLVEDprotection_level = 66.3728, z = 0.318639

M/M/1 queue — mm1_queue

Steady-state measures of a single-server queue with Poisson arrivals and exponential service: utilisation, mean numbers in system and in queue, mean times in system and in queue, probability of an empty system.

\[L = \frac{\rho}{1-\rho},\; W = \frac{1}{\mu - \lambda},\; W_q = \frac{\rho}{\mu-\lambda}\]
inputmeaningcondition
lamarrival rate (customers per unit time)
muservice rate (customers per unit time)
outputmeaning
rhoutilisation lambda/mu
Lmean number in the system
Lqmean number waiting
Wmean time in the system (time unit of the rates)
Wqmean waiting time in the queue
P0probability the system is empty
M/M/1 queue: mean number in the system against arrival rate (customers per unit time)L (mean number in the system) against lam (arrival rate (customers per unit time)) from 4 to 12. One curve for each value of mu (service rate (customers per unit time)): 10, 20. 23 points per curve computed by optimization-ai999x; marked: the worked example, lam = 8, L = 4.468101202040604mu = 10 (example)mu = 20lam — arrival rate (customers per unit time)L — mean number in the system
L (mean number in the system) against lam (arrival rate (customers per unit time)) from 4 to 12. One curve for each value of mu (service rate (customers per unit time)): 10, 20. 23 points per curve computed by optimization-ai999x; marked: the worked example, lam = 8, L = 4.
optimization_ai999x.solve('mm1_queue', lam=8, mu=10)
# -> rho = 0.8, L = 4, Lq = 3.2, W = 0.5, Wq = 0.4, P0 = 0.2   (SOLVED)
optimization_ai999x.solve('mm1_queue', lam=2, mu=3)
# -> rho = 0.666667, L = 2, Lq = 1.33333, W = 1, Wq = 0.666667, P0 = 0.333333   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
In an M/M/1 queue customers arrive at 8 per hour and are served at 10 per hour. Find L, Lq, W and Wq.SOLVEDrho = 0.8, L = 4, Lq = 3.2, W = 0.5, Wq = 0.4, P0 = 0.2
A single-server queue has an arrival rate of 2 per minute and a service rate of 3 per minute. What is the mean time in the system?SOLVEDrho = 0.666667, L = 2, Lq = 1.33333, W = 1, Wq = 0.666667, P0 = 0.333333
In an M/M/1 queue customers arrive at 12 per hour and are served at 10 per hour. Find L.INVALID_INPUTM/M/1 queue: the queue is unstable: the arrival rate must be below the service rate.

M/M/c queue (Erlang C) — mmc_queue

Steady-state measures of a queue with c parallel identical servers, Poisson arrivals and exponential service: probability of waiting (Erlang C), mean queue length and waiting times.

\[C(c, a) = \frac{B(c,a)}{1 - \rho(1 - B(c,a))}, \quad L_q = C\,\frac{\rho}{1-\rho}\]
inputmeaningcondition
lamarrival rate
muservice rate of each server
cnumber of servers
outputmeaning
rhoutilisation lambda/(c mu)
P_waitprobability an arrival waits (Erlang C)
Lqmean number waiting
Wqmean waiting time
Wmean time in the system
Lmean number in the system
P0probability the system is empty
M/M/c queue (Erlang C): mean number waiting against service rate of each serverLq (mean number waiting) against mu (service rate of each server) from 1.5 to 4.5. One curve for each value of c (number of servers): 2, 3, 4. Other inputs as in the worked example: lam = 2. 31 points per curve computed by optimization-ai999x; marked: the worked example, mu = 3, Lq = 0.0833333.23400.250.50.7510.0833333c = 2 (example)c = 3c = 4mu — service rate of each serverLq — mean number waiting
Lq (mean number waiting) against mu (service rate of each server) from 1.5 to 4.5. One curve for each value of c (number of servers): 2, 3, 4. Other inputs as in the worked example: lam = 2. 31 points per curve computed by optimization-ai999x; marked: the worked example, mu = 3, Lq = 0.0833333.
optimization_ai999x.solve('mmc_queue', lam=2, mu=3, c=2)
# -> rho = 0.333333, P_wait = 0.166667, Lq = 0.0833333, Wq = 0.0416667, W = 0.375, L = 0.75, P0 = 0.5   (SOLVED)
optimization_ai999x.solve('mmc_queue', lam=2, mu=3, c=1)
# -> rho = 0.666667, P_wait = 0.666667, Lq = 1.33333, Wq = 0.666667, W = 1, L = 2, P0 = 0.333333   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Customers arrive at 24 per hour at a bank with 3 tellers; each teller serves 10 per hour. Find the probability of waiting and Lq for this M/M/c queue.SOLVEDrho = 0.8, P_wait = 0.647191, Lq = 2.58876, Wq = 0.107865, W = 0.207865, L = 4.98876, P0 = 0.0561798
An M/M/2 queue has arrival rate 2 per hour and service rate 3 per hour. Find Lq.SOLVEDrho = 0.333333, P_wait = 0.166667, Lq = 0.0833333, Wq = 0.0416667, W = 0.375, L = 0.75, P0 = 0.5
An M/M/2 queue has arrival rate 8 per hour and service rate 3 per hour. Find Lq.INVALID_INPUTM/M/c queue (Erlang C): the queue is unstable: lambda must be below c * mu.

M/M/c/K queue (finite capacity) — mmck_finite_queue

Steady-state measures of a queue with c servers and room for at most K customers in the system (arrivals finding it full are lost): blocking probability, effective arrival rate, mean numbers and times.

\[\pi_n \propto \frac{a^n}{n!}\ (n \le c),\quad \frac{a^c}{c!}\left(\frac{a}{c}\right)^{n-c}\ (c < n \le K)\]
inputmeaningcondition
lamarrival rate
muservice rate of each server
cnumber of servers
Ksystem capacity (customers in service plus waiting)
outputmeaning
P_blockprobability an arrival is lost (system full)
lam_effeffective arrival rate
Lmean number in the system
Lqmean number waiting
Wmean time in the system
Wqmean waiting time
P0probability the system is empty
M/M/c/K queue (finite capacity): mean number in the system against arrival rateL (mean number in the system) against lam (arrival rate) from 0.2 to 20 on a logarithmic axis. One curve for each value of K (system capacity (customers in service plus waiting)): 3, 4, 5. Other inputs as in the worked example: mu = 2, c = 1. 41 points per curve computed by optimization-ai999x; marked: the worked example, lam = 2, L = 1.5.1100241.5K = 3 (example)K = 4K = 5lam — arrival rateL — mean number in the system
L (mean number in the system) against lam (arrival rate) from 0.2 to 20 on a logarithmic axis. One curve for each value of K (system capacity (customers in service plus waiting)): 3, 4, 5. Other inputs as in the worked example: mu = 2, c = 1. 41 points per curve computed by optimization-ai999x; marked: the worked example, lam = 2, L = 1.5.
optimization_ai999x.solve('mmck_finite_queue', lam=2, mu=2, c=1, K=3)
# -> P_block = 0.25, lam_eff = 1.5, L = 1.5, Lq = 0.75, W = 1, Wq = 0.5, P0 = 0.25   (SOLVED)
optimization_ai999x.solve('mmck_finite_queue', lam=3, mu=1, c=2, K=2)
# -> P_block = 0.529412, lam_eff = 1.41176, L = 1.41176, Lq = 0, W = 1, Wq = 0, P0 = 0.117647   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
An M/M/1/3 queue has arrival rate 2 per hour and service rate 2 per hour. Find the blocking probability and L.SOLVEDP_block = 0.25, lam_eff = 1.5, L = 1.5, Lq = 0.75, W = 1, Wq = 0.5, P0 = 0.25
An M/M/2/2 queue has arrival rate 3 per hour and service rate 1 per hour. Find the probability an arrival is lost.SOLVEDP_block = 0.529412, lam_eff = 1.41176, L = 1.41176, Lq = 0, W = 1, Wq = 0, P0 = 0.117647

Erlang B blocking probability (M/M/c/c loss system) — erlang_b

The probability that a call (customer) is blocked in a loss system with c servers and no waiting room, for an offered traffic of A erlangs, with the carried and lost traffic.

\[B(c, A) = \frac{A^c / c!}{\sum_{k=0}^{c} A^k / k!}\]
inputmeaningcondition
Aoffered traffic in erlangs (arrival rate x mean holding time)
cnumber of servers (lines, trunks)
outputmeaning
blocking_probabilityErlang B blocking probability
carried_trafficcarried traffic A $(1 - B)$, erlangs
lost_trafficlost traffic A B, erlangs
Erlang B blocking probability (M/M/c/c loss system): Erlang B blocking probability against offered traffic…blocking_probability (Erlang B blocking probability) against A (offered traffic in erlangs (arrival rate x mean holding time)) from 0.3 to 30 on a logarithmic axis, logarithmic output axis. One curve for each value of c (number of servers (lines, trunks)): 5, 2, 10. 41 points per curve computed by optimization-ai999x; marked: the worked example, A = 3, blocking_probability = 0.110054.1101.00e-121.00e-91.00e-60.00110.110054c = 5 (example)c = 2c = 10A — offered traffic in erlangsblocking_probability
blocking_probability (Erlang B blocking probability) against A (offered traffic in erlangs (arrival rate x mean holding time)) from 0.3 to 30 on a logarithmic axis, logarithmic output axis. One curve for each value of c (number of servers (lines, trunks)): 5, 2, 10. 41 points per curve computed by optimization-ai999x; marked: the worked example, A = 3, blocking_probability = 0.110054.
Erlang B blocking probability (M/M/c/c loss system): Erlang B blocking probability over offered traffic in…blocking_probability (Erlang B blocking probability) over A (offered traffic in erlangs (arrival rate x mean holding time)) from 0.3 to 30 and c (number of servers (lines, trunks)) from 1 to 13 (logarithmic horizontal axis): each of the 21 × 13 cells is one run of optimization-ai999x, shaded by its value (light 1.8967e-17 to dark 0.967742, logarithmic shading); iso-lines at blocking_probability = 1.00e-15, 1.00e-14, 1.00e-13, 1.00e-12, 1.00e-11, 1.00e-10. Marked: the worked example, A = 3, c = 5, blocking_probability = 0.110054.1105101.00e-151.00e-141.00e-131.00e-121.00e-111.00e-100.1100540.9677421.90e-17blocking_pA — offered traffic in erlangsc — number of servers (lines, trunks)
blocking_probability (Erlang B blocking probability) over A (offered traffic in erlangs (arrival rate x mean holding time)) from 0.3 to 30 and c (number of servers (lines, trunks)) from 1 to 13 (logarithmic horizontal axis): each of the 21 × 13 cells is one run of optimization-ai999x, shaded by its value (light 1.8967e-17 to dark 0.967742, logarithmic shading); iso-lines at blocking_probability = 1.00e-15, 1.00e-14, 1.00e-13, 1.00e-12, 1.00e-11, 1.00e-10. Marked: the worked example, A = 3, c = 5, blocking_probability = 0.110054.
optimization_ai999x.solve('erlang_b', A=3, c=5)
# -> blocking_probability = 0.110054, carried_traffic = 2.66984, lost_traffic = 0.330163   (SOLVED)
optimization_ai999x.solve('erlang_b', A=1, c=1)
# -> blocking_probability = 0.5, carried_traffic = 0.5, lost_traffic = 0.5   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
A trunk group of 5 lines is offered traffic of 3 erlangs. What is the Erlang B blocking probability?SOLVEDblocking_probability = 0.110054, carried_traffic = 2.66984, lost_traffic = 0.330163

Machine-repair (finite-source) queue — machine_repair_queue

N machines each fail at rate lambda while running and c repairers fix them at rate mu each: mean number of machines down and waiting, failure rate, downtime and the mean number working.

\[\pi_n \propto \frac{N!}{(N-n)!}\,\frac{(\lambda/\mu)^n}{n!\ \text{or}\ c!\,c^{n-c}}\]
inputmeaningcondition
Nnumber of machines
lamfailure rate of one running machine
murepair rate of one repairer
cnumber of repairers (default 1)
outputmeaning
Lmean number of machines down
Lqmean number waiting for repair
lam_effmean failure rate lambda (N - L)
Wmean downtime per failure
Wqmean wait for a repairer
P0probability all machines run
workingmean number running
Machine-repair (finite-source) queue: mean number of machines down against number of machinesL (mean number of machines down) against N (number of machines) from 1 to 10. One curve for each value of lam (failure rate of one running machine): 1, 0.5, 2. Other inputs as in the worked example: mu = 1, c = 1. 10 points per curve computed by optimization-ai999x; marked: the worked example, N = 2, L = 1.2.2.557.51002.557.5101.2lam = 1 (example)lam = 0.5lam = 2N — number of machinesL — mean number of machines down
L (mean number of machines down) against N (number of machines) from 1 to 10. One curve for each value of lam (failure rate of one running machine): 1, 0.5, 2. Other inputs as in the worked example: mu = 1, c = 1. 10 points per curve computed by optimization-ai999x; marked: the worked example, N = 2, L = 1.2.
optimization_ai999x.solve('machine_repair_queue', N=2, lam=1, mu=1, c=1)
# -> L = 1.2, Lq = 0.4, lam_eff = 0.8, W = 1.5, Wq = 0.5, P0 = 0.2, working = 0.8   (SOLVED)
optimization_ai999x.solve('machine_repair_queue', N=5, lam=0.2, mu=1, c=1)
# -> L = 1.42434, Lq = 0.709207, lam_eff = 0.715132, W = 1.99171, Wq = 0.991714, P0 = 0.284868, working = 3.57566   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
There are 5 machines; each machine breaks down at a rate of 0.2 per hour and one repairer repairs at a rate of 1 per hour. Find the mean number of machines down.SOLVEDL = 1.42434, Lq = 0.709207, lam_eff = 0.715132, W = 1.99171, Wq = 0.991714, P0 = 0.284868, working = 3.57566

M/G/1 queue (Pollaczek-Khinchine formula) — mg1_pollaczek_khinchine

Mean queue length and waiting times of a single-server queue with Poisson arrivals and a GENERAL service time distribution given by its mean and standard deviation (M/D/1 when the standard deviation is 0).

\[L_q = \frac{\lambda^2 \sigma_S^2 + \rho^2}{2(1-\rho)}\]
inputmeaningcondition
lamarrival rate
ESmean service time (time unit of 1/lambda)
sdstandard deviation of the service time
outputmeaning
rhoutilisation lambda E[S]
Lqmean number waiting
Lmean number in the system
Wqmean waiting time
Wmean time in the system
M/G/1 queue (Pollaczek-Khinchine formula): mean number waiting against standard deviation of the service timeLq (mean number waiting) against sd (standard deviation of the service time) from 0.1 to 10 on a logarithmic axis. One curve for each value of lam (arrival rate): 0.5, 0.25. Other inputs as in the worked example: ES = 1. 41 points per curve computed by optimization-ai999x; marked: the worked example, sd = 1, Lq = 0.5.0.1110010200.5lam = 0.5 (example)lam = 0.25sd — standard deviation of the service timeLq — mean number waiting
Lq (mean number waiting) against sd (standard deviation of the service time) from 0.1 to 10 on a logarithmic axis. One curve for each value of lam (arrival rate): 0.5, 0.25. Other inputs as in the worked example: ES = 1. 41 points per curve computed by optimization-ai999x; marked: the worked example, sd = 1, Lq = 0.5.
optimization_ai999x.solve('mg1_pollaczek_khinchine', lam=0.5, ES=1, sd=1)
# -> rho = 0.5, Lq = 0.5, L = 1, Wq = 1, W = 2   (SOLVED)
optimization_ai999x.solve('mg1_pollaczek_khinchine', lam=0.5, ES=1, sd=0)
# -> rho = 0.5, Lq = 0.25, L = 0.75, Wq = 0.5, W = 1.5   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
In an M/G/1 queue the arrival rate is 0.5 per minute, the mean service time is 1 minute and its standard deviation is 1 minute. Find Lq.SOLVEDrho = 0.5, Lq = 0.5, L = 1, Wq = 1, W = 2
An M/D/1 queue has an arrival rate of 0.5 per minute and a constant service time of 1 minute. Find Wq.SOLVEDrho = 0.5, Lq = 0.25, L = 0.75, Wq = 0.5, W = 1.5
In an M/G/1 queue the arrival rate is 2 per minute, the mean service time is 1 minute and its standard deviation is 1 minute. Find Lq.INVALID_INPUTM/G/1 queue (Pollaczek-Khinchine formula): the queue is unstable: lambda times the mean service time must be below 1.

Minimum number of servers for a service target (Erlang C) — mmc_staffing

The smallest number of servers c of an M/M/c queue for which the probability of waiting, or the mean waiting time, meets a target.

\[c^* = \min\{c > \lambda/\mu : C(c, \lambda/\mu) \le \alpha\}\]
inputmeaningcondition
lamarrival rate
muservice rate of each server
targettarget value (a probability, or a mean wait in the time unit of the rates)
criterionwait_probability (default) or mean_wait
outputmeaning
serversminimum number of servers
P_waitprobability of waiting with that many servers
Wqmean waiting time with that many servers
utilisationserver utilisation
Minimum number of servers for a service target (Erlang C): minimum number of servers against service rate o…servers (minimum number of servers) against mu (service rate of each server) from 1 to 100 on a logarithmic axis. One curve for each value of lam (arrival rate): 24, 12, 48. Other inputs as in the worked example: target = 0.2. 41 points per curve computed by optimization-ai999x; marked: the worked example, mu = 10, servers = 5.11010002040605lam = 24 (example)lam = 12lam = 48mu — service rate of each serverservers — minimum number of servers
servers (minimum number of servers) against mu (service rate of each server) from 1 to 100 on a logarithmic axis. One curve for each value of lam (arrival rate): 24, 12, 48. Other inputs as in the worked example: target = 0.2. 41 points per curve computed by optimization-ai999x; marked: the worked example, mu = 10, servers = 5.
optimization_ai999x.solve('mmc_staffing', lam=24, mu=10, target=0.2)
# -> servers = 5, P_wait = 0.113504, Wq = 0.00436553, utilisation = 0.48   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Calls arrive at 24 per hour and each agent serves 10 per hour. How many agents are needed so that the probability of waiting is at most 0.2?SOLVEDservers = 5, P_wait = 0.113504, Wq = 0.00436553, utilisation = 0.48

Shortest processing time rule (minimum mean flow time) — spt_mean_flow_time

The job order that minimises the mean flow (completion) time on one machine, and that minimum.

\[\min \tfrac{1}{n}\sum_j C_j:\; p_{[1]} \le p_{[2]} \le \dots\]
inputmeaningcondition
pprocessing time of each job (jobs numbered 1, 2, ...)
outputmeaning
mean_flow_timeminimum mean completion time
total_completion_timeminimum total completion time
sequenceoptimal job order (shortest first; equal times in job-number order)
Shortest processing time rule (minimum mean flow time): optimal job order (shortest first; equal times in j…optimal job order (shortest first; equal times in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 3, largest 4). Inputs: p = 4, 2, 6, 3.123401234position in the listsequence — optimal job order
optimal job order (shortest first; equal times in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 3, largest 4). Inputs: p = 4, 2, 6, 3.
optimization_ai999x.solve('spt_mean_flow_time', p='4, 2, 6, 3')
# -> sequence = [2, 4, 1, 3], total_completion_time = 31, mean_flow_time = 7.75   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Jobs with processing times [4, 2, 6, 3] are done on one machine. Find the sequence that minimizes the mean flow time.SOLVEDsequence = [2, 4, 1, 3], total_completion_time = 31, mean_flow_time = 7.75

Weighted shortest processing time (Smith's rule) — wspt_weighted_completion

The job order that minimises the total weighted completion time on one machine, and that minimum.

\[\min \sum_j w_j C_j:\; \frac{p_{[1]}}{w_{[1]}} \le \frac{p_{[2]}}{w_{[2]}} \le \dots\]
inputmeaningcondition
pprocessing time of each job
wweight (importance) of each job
outputmeaning
weighted_completion_timeminimum total weighted completion time
sequenceoptimal order (ratio p/w ascending; ties in job-number order)
Weighted shortest processing time (Smith's rule): optimal order (ratio p/w ascending; ties in job-number or…optimal order (ratio p/w ascending; ties in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each w (weight (importance) of each job) (3 values, first 2, last 1, largest 3). Inputs: p = [3, 1, 4], w = [1, 2, 3].11.522.530123w — weight (importance) of each jobsequence — optimal order
optimal order (ratio p/w ascending; ties in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each w (weight (importance) of each job) (3 values, first 2, last 1, largest 3). Inputs: p = [3, 1, 4], w = [1, 2, 3].
optimization_ai999x.solve('wspt_weighted_completion', p=[3, 1, 4], w=[1, 2, 3])
# -> sequence = [2, 3, 1], weighted_completion_time = 25   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Jobs have processing times [3, 1, 4] and weights [1, 2, 3]. Find the sequence minimizing the total weighted completion time.SOLVEDsequence = [2, 3, 1], weighted_completion_time = 25

Earliest due date rule (minimum maximum lateness) — edd_max_lateness

The job order that minimises the maximum lateness (and so the maximum tardiness) on one machine.

\[\min L_{\max} = \min \max_j (C_j - d_j):\; d_{[1]} \le d_{[2]} \le \dots\]
inputmeaningcondition
pprocessing time of each job
ddue date of each job
outputmeaning
max_latenessminimum possible maximum lateness
max_tardinessminimum possible maximum tardiness
sequenceoptimal order (earliest due date first; ties in job-number order)
tardy_jobs_in_sequencenumber of late jobs in this sequence (not minimised)
Earliest due date rule (minimum maximum lateness): optimal order (earliest due date first; ties in job-numb…optimal order (earliest due date first; ties in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 3, last 4, largest 4). Inputs: p = [2, 4, 1, 3], d = [5, 6, 3, 9].123401234position in the listsequence — optimal order
optimal order (earliest due date first; ties in job-number order) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 3, last 4, largest 4). Inputs: p = [2, 4, 1, 3], d = [5, 6, 3, 9].
optimization_ai999x.solve('edd_max_lateness', p=[2, 4, 1, 3], d=[5, 6, 3, 9])
# -> sequence = [3, 1, 2, 4], max_lateness = 1, max_tardiness = 1, tardy_jobs_in_sequence = 2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Jobs have processing times [2, 4, 1, 3] and due dates [5, 6, 3, 9]. Find the sequence that minimizes the maximum lateness.SOLVEDsequence = [3, 1, 2, 4], max_lateness = 1, max_tardiness = 1, tardy_jobs_in_sequence = 2

Moore-Hodgson algorithm (minimum number of tardy jobs) — moore_hodgson_tardy_jobs

The smallest possible number of late jobs on one machine, with an order of the on-time jobs and the set of late jobs.

\[\min \sum_j U_j\]
inputmeaningcondition
pprocessing time of each job
ddue date of each job
outputmeaning
min_tardy_jobsminimum number of tardy jobs
on_time_sequenceon-time jobs in due-date order
tardy_jobsjobs scheduled late (one optimal choice: the longest job removed, ties the higher job number)
Moore-Hodgson algorithm (minimum number of tardy jobs): on-time jobs in due-date orderon-time jobs in due-date order (on_time_sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 2, last 4, largest 4). Inputs: p = [4, 3, 2, 5, 6], d = [5, 6, 8, 12, 15].12301234position in the liston_time_sequence
on-time jobs in due-date order (on_time_sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 2, last 4, largest 4). Inputs: p = [4, 3, 2, 5, 6], d = [5, 6, 8, 12, 15].
optimization_ai999x.solve('moore_hodgson_tardy_jobs', p=[4, 3, 2, 5, 6], d=[5, 6, 8, 12, 15])
# -> min_tardy_jobs = 2, on_time_sequence = [2, 3, 4], tardy_jobs = [1, 5]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Jobs have processing times [4, 3, 2, 5, 6] and due dates [5, 6, 8, 12, 15]. Find the minimum number of tardy jobs.SOLVEDmin_tardy_jobs = 2, on_time_sequence = [2, 3, 4], tardy_jobs = [1, 5]

Johnson's rule (two-machine flow shop) — johnson_two_machine

The job order that minimises the makespan when every job is processed first on machine 1 and then on machine 2.

\[\min C_{\max} \text{ for } F2 \| C_{\max}\]
inputmeaningcondition
aprocessing time of each job on machine 1
bprocessing time of each job on machine 2
outputmeaning
makespanminimum makespan
sequenceJohnson order (a < b by increasing a, then the rest by decreasing b; ties by job number)
A two-machine schedule in Johnson's orderA two-machine flow shop: processing times [5, 2, 6, 7] on machine 1 and [3, 4, 8, 2] on machine 2. The package's Johnson order is job 2 → job 3 → job 1 → job 4, with makespan 22; each job starts on machine 2 as soon as it leaves machine 1 and machine 2 is free.05101520J2J2J3J3J1J1J4J4machine 1machine 2makespan 22job 2job 3job 1job 4time
A two-machine flow shop: processing times [5, 2, 6, 7] on machine 1 and [3, 4, 8, 2] on machine 2. The package's Johnson order is job 2 → job 3 → job 1 → job 4, with makespan 22; each job starts on machine 2 as soon as it leaves machine 1 and machine 2 is free.
Johnson's rule (two-machine flow shop): Johnson order (a < b by increasing a, then the rest by decreasing b…Johnson order (a < b by increasing a, then the rest by decreasing b; ties by job number) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 4, largest 4). Inputs: a = [5, 2, 6, 7], b = [3, 4, 8, 2].123401234position in the listsequence — Johnson order
Johnson order (a < b by increasing a, then the rest by decreasing b; ties by job number) (sequence) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 4, largest 4). Inputs: a = [5, 2, 6, 7], b = [3, 4, 8, 2].
optimization_ai999x.solve('johnson_two_machine', a=[5, 2, 6, 7], b=[3, 4, 8, 2])
# -> makespan = 22, sequence = [2, 3, 1, 4]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Use Johnson's rule: machine 1 times [5, 2, 6, 7] and machine 2 times [3, 4, 8, 2]. Find the minimum makespan.SOLVEDmakespan = 22, sequence = [2, 3, 1, 4]

Minimum makespan on identical parallel machines — parallel_machine_makespan

Assign jobs to m identical machines so that the last machine finishes as early as possible (P||Cmax), exactly.

\[\min_{\text{assignment}} \max_k \sum_{j \to k} p_j\]
inputmeaningcondition
pprocessing time of each job
mnumber of identical machines
outputmeaning
makespanminimum makespan
machine_of_jobone optimal assignment: machine number of each job
lower_boundthe bound max(longest job, total / m)
Minimum makespan on identical parallel machines: one optimal assignment: machine number of each jobone optimal assignment: machine number of each job (machine_of_job) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 1, last 1, largest 2). Inputs: p = [7, 5, 4, 3, 3, 2], m = 2.24600.511.52position in the listmachine_of_job
one optimal assignment: machine number of each job (machine_of_job) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 1, last 1, largest 2). Inputs: p = [7, 5, 4, 3, 3, 2], m = 2.
Minimum makespan on identical parallel machines: minimum makespan against number of identical machinesmakespan (minimum makespan) against m (number of identical machines) from 1 to 10. Other inputs as in the worked example: p = [7, 5, 4, 3, 3, 2]. 6 points computed by optimization-ai999x; marked: the worked example, m = 2, makespan = 12.2460102012m — number of identical machinesmakespan — minimum makespan
makespan (minimum makespan) against m (number of identical machines) from 1 to 10. Other inputs as in the worked example: p = [7, 5, 4, 3, 3, 2]. 6 points computed by optimization-ai999x; marked: the worked example, m = 2, makespan = 12.
optimization_ai999x.solve('parallel_machine_makespan', p=[7, 5, 4, 3, 3, 2], m=2)
# -> makespan = 12, machine_of_job = [1, 2, 2, 1, 2, 1], lower_bound = 12   (SOLVED)
optimization_ai999x.solve('parallel_machine_makespan', p=[3, 3, 2, 2, 2], m=2)
# -> makespan = 6, machine_of_job = [1, 1, 2, 2, 2], lower_bound = 6   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Jobs with processing times [7, 5, 4, 3, 3, 2] are scheduled on 2 identical machines. Find the minimum makespan.SOLVEDmakespan = 12, machine_of_job = [1, 2, 2, 1, 2, 1], lower_bound = 12

Critical path method (project duration and slack) — critical_path_method

For activities with durations and precedences, the minimum project duration, the critical activities and each activity's earliest start, latest start and slack (total float).

\[ES_k = \max_{j \to k}(ES_j + d_j),\quad LS_k = \min_{k \to s} LS_s - d_k,\quad \text{slack}_k = LS_k - ES_k\]
inputmeaningcondition
durationsduration of each activity; activities are named A, B, C, ... (or 1, 2, 3, ...) in this order
precedencesprecedence pairs 'A-B' meaning A must finish before B starts (none if omitted)
outputmeaning
project_durationminimum project duration
critical_activitiesactivities with zero slack
slacktotal slack of each activity
earliest_startearliest start of each activity
latest_startlatest start of each activity
Critical path method (project duration and slack): total slack of each activitytotal slack of each activity (slack) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 0, last 0, largest 2); with earliest_start (earliest start of each activity), latest_start (latest start of each activity). Inputs: durations = 3, 4, 2, 5, precedences = A-B, A-C, B-D, C-D.12340246slack — total slack of each activityearliest_start — earliest start of each actilatest_start — latest start of each activityposition in the listslack — total slack of each activity
total slack of each activity (slack) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 0, last 0, largest 2); with earliest_start (earliest start of each activity), latest_start (latest start of each activity). Inputs: durations = 3, 4, 2, 5, precedences = A-B, A-C, B-D, C-D.
Critical path method (project duration and slack): the networkThe network precedences (precedence pairs 'A-B' meaning A must finish before B starts (none if omitted)) of the worked example (4 nodes, 4 edges, laid out on a circle); highlighted: the returned path A → B → D. Returned: project_duration = 12. Other inputs: durations = 3, 4, 2, 5.ABCDreturned path
The network precedences (precedence pairs 'A-B' meaning A must finish before B starts (none if omitted)) of the worked example (4 nodes, 4 edges, laid out on a circle); highlighted: the returned path A → B → D. Returned: project_duration = 12. Other inputs: durations = 3, 4, 2, 5.
optimization_ai999x.solve('critical_path_method', durations='3, 4, 2, 5', precedences='A-B, A-C, B-D, C-D')
# -> project_duration = 12, critical_activities = ['A', 'B', 'D'], slack = [0.0, 0.0, 2.0, 0.0], earliest_start = [0.0, 3.0, 3.0, 7.0], latest_start = [0.0, 3.0, 5.0, 7.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Activities A, B, C, D have durations [3, 4, 2, 5]; precedences: A-B, A-C, B-D, C-D. Find the critical path and the project duration.SOLVEDproject_duration = 12, critical_activities = ['A', 'B', 'D'], slack = [0.0, 0.0, 2.0, 0.0], earliest_start = [0.0, 3.0, 3.0, 7.0], latest_start = [0.0, 3.0, 5.0, 7.0]
Find the critical path: activities have durations [3, 4, 2]; precedences: A-B, B-C, C-A.INVALID_INPUTCritical path method (project duration and slack): the precedences contain a cycle.

PERT project duration and completion probability — pert_project

With optimistic, most likely and pessimistic times per activity, the expected project duration, its variance along the critical path and the probability of finishing by a deadline (normal approximation).

\[t_e = \frac{a + 4m + b}{6},\; \sigma^2 = \left(\frac{b - a}{6}\right)^2,\; P(T \le d) = \Phi\!\left(\frac{d - \mu}{\sigma}\right)\]
inputmeaningcondition
timesrows (optimistic, most likely, pessimistic), one per activity A, B, C, ...
precedencesprecedence pairs 'A-B' (A before B)
deadlinedeadline for the completion probability (optional)
outputmeaning
expected_durationexpected project duration
variancevariance of the critical path
std_devstandard deviation
critical_paththe critical path (must be unique)
expected_timesexpected time of each activity $(a + 4m + b)/6$
probabilityprobability of completion by the deadline
PERT project duration and completion probability: expected time of each activity (a + 4m + b)/6expected time of each activity (a + 4m + b)/6 (expected_times) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 4, last 2, largest 6). Inputs: times = 2 4 6; 3 5 13; 1 2 3, precedences = A-B, A-C, deadline = 10.1230246position in the listexpected_times
expected time of each activity (a + 4m + b)/6 (expected_times) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 4, last 2, largest 6). Inputs: times = 2 4 6; 3 5 13; 1 2 3, precedences = A-B, A-C, deadline = 10.
PERT project duration and completion probability: the networkThe network precedences (precedence pairs 'A-B' (A before B)) of the worked example (3 nodes, 2 edges, laid out on a circle); highlighted: the returned path A → B. Returned: expected_duration = 10, variance = 3.22222, std_dev = 1.79505, probability = 0.5. Other inputs: times = 2 4 6; 3 5 13; 1 2 3, deadline = 10.ABCreturned path
The network precedences (precedence pairs 'A-B' (A before B)) of the worked example (3 nodes, 2 edges, laid out on a circle); highlighted: the returned path A → B. Returned: expected_duration = 10, variance = 3.22222, std_dev = 1.79505, probability = 0.5. Other inputs: times = 2 4 6; 3 5 13; 1 2 3, deadline = 10.
optimization_ai999x.solve('pert_project', times='2 4 6; 3 5 13; 1 2 3', precedences='A-B, A-C', deadline=10)
# -> expected_duration = 10, variance = 3.22222, std_dev = 1.79505, critical_path = ['A', 'B'], expected_times = [4.0, 6.0, 2.0], probability = 0.5   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
PERT: activities A, B, C have times [[2, 4, 6], [3, 5, 13], [1, 2, 3]]; precedences: A-B, A-C. Find the expected project duration.SOLVEDexpected_duration = 10, variance = 3.22222, std_dev = 1.79505, critical_path = ['A', 'B'], expected_times = [4.0, 6.0, 2.0]
PERT: activities A, B have times [[2, 4, 6], [2, 4, 6]]. Find the expected project duration.INVALID_INPUTPERT project duration and completion probability: there is more than one critical path, so the PERT variance of the proj

Shortest path (Dijkstra's algorithm) — shortest_path

The length of the shortest route between two nodes of a graph with non-negative edge weights, and the route itself (stated as the route only when it is the only shortest one).

\[d(v) = \min_{(u,v)} \big(d(u) + w_{uv}\big)\]
inputmeaningcondition
edgesweighted edges 'A-B 4, B-C 1, ...'
sourcestart node
targetend node
directedtrue for a directed graph (edge u-v goes from u to v), false for undirected
outputmeaning
distanceshortest distance
paththe shortest path (only when unique; otherwise path_example)
path_uniqueyes when exactly one shortest path exists
Shortest path and minimum spanning treeA weighted network (A-B 4, A-C 2, B-C 1, B-D 5, C-D 8, A-E 7, E-D 3, C-E 6): the shortest path from A to D the package finds, A → C → B → D of length 8, and its minimum spanning tree (B-C, A-C, E-D, B-D, total weight 11).42158736ABDECother edgesminimum spanning tree, weight 11shortest path A → D, length 8
A weighted network (A-B 4, A-C 2, B-C 1, B-D 5, C-D 8, A-E 7, E-D 3, C-E 6): the shortest path from A to D the package finds, A → C → B → D of length 8, and its minimum spanning tree (B-C, A-C, E-D, B-D, total weight 11).
Shortest path (Dijkstra's algorithm): the networkThe network edges (weighted edges 'A-B 4, B-C 1, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight; highlighted: the returned path A → C → B → D. Returned: distance = 8. Other inputs: source = A, target = D, directed = False.42158ABCDreturned path
The network edges (weighted edges 'A-B 4, B-C 1, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight; highlighted: the returned path A → C → B → D. Returned: distance = 8. Other inputs: source = A, target = D, directed = False.
optimization_ai999x.solve('shortest_path', edges='A-B 4, A-C 2, B-C 1, B-D 5, C-D 8', source='A', target='D', directed=False)
# -> distance = 8, path = ['A', 'C', 'B', 'D'], path_unique = yes   (SOLVED)
optimization_ai999x.solve('shortest_path', edges='A-B 1, B-C 1, A-C 2', source='A', target='C', directed=True)
# -> distance = 2, path_example = ['A', 'C'], path_unique = no   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the shortest path from A to D in the undirected graph with edges A-B 4, A-C 2, B-C 1, B-D 5, C-D 8.SOLVEDdistance = 8, path = ['A', 'C', 'B', 'D'], path_unique = yes
Find the shortest path from A to D in the graph with edges A-B 4, A-C 2, B-C 1, B-D 5, C-D 8.NEEDS_INPUTshortest_path needs directed (true for a directed graph (edge u-v goes from u to v), false for undirected). Example: sol
Find the shortest path from A to E in the directed graph with edges A-B 4, B-C 1.INVALID_INPUTShortest path (Dijkstra's algorithm): the source and the target must be nodes of the graph.

Shortest path with negative weights (Bellman-Ford) — bellman_ford_shortest_path

Shortest distance in a directed graph whose edge weights may be negative, with all distances from the source; a negative cycle reachable from the source is reported instead of a number.

\[d(v) \le d(u) + w_{uv} \ \forall (u,v)\]
inputmeaningcondition
edgesdirected weighted edges 'A-B 4, $B-C -2$, ...'
sourcestart node
targetend node
outputmeaning
distanceshortest distance from source to target
distances_from_sourceshortest distance to every reachable node
Shortest path with negative weights (Bellman-Ford): shortest distance to every reachable nodeshortest distance to every reachable node (distances_from_source) returned by optimization-ai999x for the worked example (edges = [["S", "A", 4], ["S", "B", 5], ["A", "T", 3]…, source = S, target = T), one bar per entry: S = 0, A = 2, B = 5, T = 5.024SABT0255distances_from_source
shortest distance to every reachable node (distances_from_source) returned by optimization-ai999x for the worked example (edges = [["S", "A", 4], ["S", "B", 5], ["A", "T", 3]…, source = S, target = T), one bar per entry: S = 0, A = 2, B = 5, T = 5.
Shortest path with negative weights (Bellman-Ford): the networkThe network edges (directed weighted edges 'A-B 4, B-C -2, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: distance = 5. Other inputs: source = S, target = T.453-36SABT
The network edges (directed weighted edges 'A-B 4, B-C -2, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: distance = 5. Other inputs: source = S, target = T.
optimization_ai999x.solve('bellman_ford_shortest_path', edges=[['S', 'A', 4], ['S', 'B', 5], ['A', 'T', 3], ['B', 'A', -3], ['B', 'T', 6]], source='S', target='T')
# -> distance = 5, distances_from_source = {'S': 0.0, 'A': 2.0, 'B': 5.0, 'T': 5.0}   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
With negative weights allowed, find the shortest path from S to T in the directed graph with edges S-A 4, S-B 5, A-T 3, B-A -3, B-T 6.SOLVEDdistance = 5, distances_from_source = {'S': 0.0, 'A': 2.0, 'B': 5.0, 'T': 5.0}
With negative weights allowed, find the shortest path from S to T in the directed graph with edges S-A 1, A-B -2, B-A 1, A-T 1.INVALID_INPUTShortest path with negative weights (Bellman-Ford): the graph has a negative cycle reachable from the source: shortest p

All-pairs shortest distances (Floyd-Warshall) — all_pairs_shortest_paths

The table of shortest distances between every pair of nodes, and the graph's diameter.

\[d_{ij} \leftarrow \min(d_{ij},\, d_{ik} + d_{kj})\]
inputmeaningcondition
edgesweighted edges 'A-B 4, ...'
directedtrue for a directed graph, false for undirected
outputmeaning
distancesshortest-distance matrix (rows and columns in the order of 'nodes')
nodesnode order (first appearance)
diameterlargest shortest distance
All-pairs shortest distances (Floyd-Warshall): the networkThe network edges (weighted edges 'A-B 4, ...') of the worked example (4 nodes, 4 edges, laid out on a circle); on each edge its stated weight; highlighted: the returned path A → B → C → D. Returned: diameter = 9. Other inputs: directed = False.3492ABCDreturned path
The network edges (weighted edges 'A-B 4, ...') of the worked example (4 nodes, 4 edges, laid out on a circle); on each edge its stated weight; highlighted: the returned path A → B → C → D. Returned: diameter = 9. Other inputs: directed = False.
All-pairs shortest distances (Floyd-Warshall): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): distances (returned). Returned with them by optimization-ai999x: diameter = 9. Other inputs: edges = A-B 3, B-C 4, A-C 9, C-D 2, directed = False.037930467402962012341234distances (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): distances (returned). Returned with them by optimization-ai999x: diameter = 9. Other inputs: edges = A-B 3, B-C 4, A-C 9, C-D 2, directed = False.
optimization_ai999x.solve('all_pairs_shortest_paths', edges='A-B 3, B-C 4, A-C 9, C-D 2', directed=False)
# -> nodes = ['A', 'B', 'C', 'D'], distances = [[0.0, 3.0, 7.0, 9.0], [3.0, 0.0, 4.0, 6.0], [7.0, 4.0, 0.0, 2.0], [9.0, 6.0, 2.0, 0.0]], diameter = 9   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the all-pairs shortest distances in the undirected graph with edges A-B 3, B-C 4, A-C 9, C-D 2.SOLVEDnodes = ['A', 'B', 'C', 'D'], distances = [[0.0, 3.0, 7.0, 9.0], [3.0, 0.0, 4.0, 6.0], [7.0, 4.0, 0.0, 2.0], [9.0, 6.0, 2.0, 0.0]], diameter = 9

Minimum spanning tree (Kruskal's algorithm) — minimum_spanning_tree

The least total weight of edges connecting all nodes of an undirected graph, and the tree (stated as THE tree only when the minimum spanning tree is unique).

\[\min_{T \text{ spanning tree}} \sum_{e \in T} w_e\]
inputmeaningcondition
edgesundirected weighted edges 'A-B 4, ...'
outputmeaning
total_weightweight of a minimum spanning tree
tree_edgesthe minimum spanning tree (only when unique; otherwise tree_edges_example)
tree_uniqueyes when the minimum spanning tree is unique
Minimum spanning tree (Kruskal's algorithm): the networkThe network edges (undirected weighted edges 'A-B 4, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: total_weight = 8.41258ABCD
The network edges (undirected weighted edges 'A-B 4, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: total_weight = 8.
optimization_ai999x.solve('minimum_spanning_tree', edges='A-B 4, A-C 1, B-C 2, B-D 5, C-D 8')
# -> total_weight = 8, tree_unique = yes, tree_edges = ['A-C', 'B-C', 'B-D']   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the minimum spanning tree of the graph with edges A-B 4, A-C 1, B-C 2, B-D 5, C-D 8.SOLVEDtotal_weight = 8, tree_unique = yes, tree_edges = ['A-C', 'B-C', 'B-D']
Find the minimum spanning tree of the graph with edges A-B 4, C-D 1.INVALID_INPUTMinimum spanning tree (Kruskal's algorithm): the graph is not connected: no spanning tree exists.

Maximum flow and minimum cut (Edmonds-Karp) — max_flow

The largest flow that can be sent from a source to a sink through a network of capacitated arcs, a flow achieving it and the minimum cut that proves it optimal.

\[\max |f| = \min_{(S, \bar S)} c(S, \bar S)\]
inputmeaningcondition
edgesdirected arcs with capacities 'S-A 10, A-T 5, ...'
sourcesource node
targetsink node
outputmeaning
max_flowmaximum flow value
min_cut_source_sidenodes on the source side of a minimum cut (those reachable in the final residual network)
edge_flowsflow on each arc, in input order (one maximum flow)
Maximum flow and minimum cut (Edmonds-Karp): flow on each arc, in input order (one maximum flow)flow on each arc, in input order (one maximum flow) (edge_flows) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 10, last 10, largest 10). Inputs: edges = S-A 10, S-B 5, A-B 15, A-T 5, B-T 10, source = S, target = T.1234502.557.510position in the listedge_flows — flow on each arc
flow on each arc, in input order (one maximum flow) (edge_flows) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 10, last 10, largest 10). Inputs: edges = S-A 10, S-B 5, A-B 15, A-T 5, B-T 10, source = S, target = T.
Maximum flow and minimum cut (Edmonds-Karp): the networkThe network edges (directed arcs with capacities 'S-A 10, A-T 5, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge the edge_flows returned by optimization-ai999x. Returned: max_flow = 15. Other inputs: source = S, target = T.1055510SABT
The network edges (directed arcs with capacities 'S-A 10, A-T 5, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge the edge_flows returned by optimization-ai999x. Returned: max_flow = 15. Other inputs: source = S, target = T.
optimization_ai999x.solve('max_flow', edges='S-A 10, S-B 5, A-B 15, A-T 5, B-T 10', source='S', target='T')
# -> max_flow = 15, min_cut_source_side = ['S'], edge_flows = [10.0, 5.0, 5.0, 5.0, 10.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the maximum flow from S to T in the network with edges S-A 10, S-B 5, A-B 15, A-T 5, B-T 10.SOLVEDmax_flow = 15, min_cut_source_side = ['S'], edge_flows = [10.0, 5.0, 5.0, 5.0, 10.0]

Transportation problem (minimum shipping cost) — transportation_problem

Ship from sources with given supplies to destinations with given demands at least total cost: the minimum cost and a shipping plan (stated as THE plan only when it is unique).

\[\min \sum_{ij} c_{ij} x_{ij}\ \text{s.t.}\ \sum_j x_{ij} \le s_i,\ \sum_i x_{ij} = d_j,\ x \ge 0\]
inputmeaningcondition
supplysupply of each source
demanddemand of each destination
costunit shipping cost, rows = sources, columns = destinations
outputmeaning
min_costminimum total shipping cost
shipmentsoptimal plan, rows = sources (only when unique; otherwise shipments_example)
plan_uniqueyes when the optimal plan is unique
dualdual values (u for sources, v for destinations): the optimality certificate
An optimal transportation planThe optimal transportation plan the package computes for supplies [20, 30], demands [10, 25, 15] and unit costs [[2, 3, 1], [5, 4, 8]] (rows: sources, columns: destinations; left the unit costs, right the quantities shipped): minimum total cost 150.23154812123unit cost5015525012123shipments
The optimal transportation plan the package computes for supplies [20, 30], demands [10, 25, 15] and unit costs [[2, 3, 1], [5, 4, 8]] (rows: sources, columns: destinations; left the unit costs, right the quantities shipped): minimum total cost 150.
Transportation problem (minimum shipping cost): dual values (u for sources, v for destinations): the optima…dual values (u for sources, v for destinations): the optimality certificate (dual) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first -3, last 4, largest 5). Inputs: supply = [20, 30], demand = [10, 25, 15], cost = [[2, 3, 1], [5, 4, 8]].12345-2024position in the listdual — dual values
dual values (u for sources, v for destinations): the optimality certificate (dual) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first -3, last 4, largest 5). Inputs: supply = [20, 30], demand = [10, 25, 15], cost = [[2, 3, 1], [5, 4, 8]].
Transportation problem (minimum shipping cost): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): cost (input); shipments (returned). Returned with them by optimization-ai999x: min_cost = 150. Other inputs: supply = [20, 30], demand = [10, 25, 15].23154812123cost (input)5015525012123shipments (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): cost (input); shipments (returned). Returned with them by optimization-ai999x: min_cost = 150. Other inputs: supply = [20, 30], demand = [10, 25, 15].
optimization_ai999x.solve('transportation_problem', supply=[20, 30], demand=[10, 25, 15], cost=[[2, 3, 1], [5, 4, 8]])
# -> min_cost = 150, shipments = [[5.0, 0.0, 15.0], [5.0, 25.0, 0.0]], plan_unique = yes, dual = [-3.0, 0.0, 5.0, 4.0, 4.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the transportation problem with supply [20, 30], demand [10, 25, 15] and cost matrix [[2, 3, 1], [5, 4, 8]].SOLVEDmin_cost = 150, shipments = [[5.0, 0.0, 15.0], [5.0, 25.0, 0.0]], plan_unique = yes, dual = [-3.0, 0.0, 5.0, 4.0, 4.0]
Solve the transportation problem with supply [5, 5], demand [10, 25, 15] and cost matrix [[2, 3, 1], [5, 4, 8]].INVALID_INPUTTransportation problem (minimum shipping cost): total supply is less than total demand: the demand cannot be met.

Minimum-cost flow (transshipment) — min_cost_flow

Send flow from supply nodes to demand nodes through capacitated arcs at least total cost (transshipment allowed): the minimum cost and a flow achieving it.

\[\min \sum c_{ij} x_{ij}\ \text{s.t.}\ \sum_j x_{vj} - \sum_i x_{iv} = b_v,\ 0 \le x_{ij} \le u_{ij}\]
inputmeaningcondition
capacityarc capacities, n x n (row = from node, column = to node, $0 = no$ arc)
costunit cost of each arc, n x n
supplynet supply of each node (positive = supply, negative = demand), summing to 0
outputmeaning
min_costminimum total cost
flowsoptimal flow matrix (only when unique; otherwise flows_example)
flow_uniqueyes when the optimal flow is unique
dualdual values: node potentials then arc-capacity prices
Minimum-cost flow (transshipment): dual values: node potentials then arc-capacity pricesdual values: node potentials then arc-capacity prices (dual) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 3, last 0, largest 3). Inputs: capacity = [[0, 10, 5], [0, 0, 10], [0, 0, 0]], cost = [[0, 1, 4], [0, 0, 2], [0, 0, 0]], supply = [8, 0, -8].2460123position in the listdual
dual values: node potentials then arc-capacity prices (dual) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 3, last 0, largest 3). Inputs: capacity = [[0, 10, 5], [0, 0, 10], [0, 0, 0]], cost = [[0, 1, 4], [0, 0, 2], [0, 0, 0]], supply = [8, 0, -8].
Minimum-cost flow (transshipment): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): capacity (input); cost (input); flows (returned). Returned with them by optimization-ai999x: min_cost = 24. Other inputs: supply = [8, 0, -8].01050010000123123capacity (input)014002000123123cost (input)080008000123123flows (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): capacity (input); cost (input); flows (returned). Returned with them by optimization-ai999x: min_cost = 24. Other inputs: supply = [8, 0, -8].
optimization_ai999x.solve('min_cost_flow', capacity=[[0, 10, 5], [0, 0, 10], [0, 0, 0]], cost=[[0, 1, 4], [0, 0, 2], [0, 0, 0]], supply=[8, 0, -8])
# -> min_cost = 24, flows = [[0.0, 8.0, 0.0], [0.0, 0.0, 8.0], [0.0, 0.0, 0.0]], flow_unique = yes, dual = [3.0, 2.0, 0.0, 0.0, 0.0, 0.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the minimum cost flow with capacity [[0, 10, 5], [0, 0, 10], [0, 0, 0]], cost [[0, 1, 4], [0, 0, 2], [0, 0, 0]] and supply [8, 0, -8].SOLVEDmin_cost = 24, flows = [[0.0, 8.0, 0.0], [0.0, 0.0, 8.0], [0.0, 0.0, 0.0]], flow_unique = yes, dual = [3.0, 2.0, 0.0, 0.0, 0.0, 0.0]

Assignment problem (Hungarian method), minimum total cost — assignment_min_cost

Assign each row (worker) to a different column (task) so that the total cost is as small as possible: the optimum and an optimal assignment (stated as THE assignment only when unique).

\[\min_{\sigma} \sum_i c_{i\sigma(i)} = \max \Big\{ \sum_i u_i + \sum_j v_j : u_i + v_j \le c_{ij} \Big\}\]
inputmeaningcondition
Ccost matrix, rows = workers, columns = tasks (square)
outputmeaning
min_costoptimal total cost
assignmentcolumn assigned to each row, 1-based (only when unique; otherwise assignment_example)
assignment_uniqueyes when the optimal assignment is unique
dual_urow potentials
dual_vcolumn potentials (u_i + v_j bounds every cell: the optimality certificate)
Assignment problem (Hungarian method), minimum total cost: column assigned to each row, 1-based (only when…column assigned to each row, 1-based (only when unique; otherwise assignment_example) (assignment) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 2, last 3, largest 3); with dual_u (row potentials), dual_v (column potentials (u_i + v_j bounds every cell: the optimality certificate)). Inputs: C = 9 2 7; 6 4 3; 5 8 1.123-2.502.55assignment — column assigned to each row, 1-dual_u — row potentialsdual_v — column potentials (u_i + v_j boundsposition in the listassignment — column assigned to each row
column assigned to each row, 1-based (only when unique; otherwise assignment_example) (assignment) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 2, last 3, largest 3); with dual_u (row potentials), dual_v (column potentials (u_i + v_j bounds every cell: the optimality certificate)). Inputs: C = 9 2 7; 6 4 3; 5 8 1.
Assignment problem (Hungarian method), minimum total cost: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): C (input); assignment (returned). Returned with them by optimization-ai999x: min_cost = 9.927643581123123C (input)213123assignment (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): C (input); assignment (returned). Returned with them by optimization-ai999x: min_cost = 9.
optimization_ai999x.solve('assignment_min_cost', C='9 2 7; 6 4 3; 5 8 1')
# -> min_cost = 9, assignment = [2, 1, 3], assignment_unique = yes, dual_u = [4.0, 6.0, 4.0], dual_v = [0.0, -2.0, -3.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the assignment problem with cost matrix [[9, 2, 7], [6, 4, 3], [5, 8, 1]].SOLVEDmin_cost = 9, assignment = [2, 1, 3], assignment_unique = yes, dual_u = [4.0, 6.0, 4.0], dual_v = [0.0, -2.0, -3.0]
Solve the assignment problem with cost matrix [[9, 2, 7], [6, 4, 3]].INVALID_INPUTAssignment problem (Hungarian method), minimum total cost: give a square matrix with at most 12 rows (add dummy rows or

Assignment problem (Hungarian method), maximum total value — assignment_max_profit

Assign each row (worker) to a different column (task) so that the total value is as large as possible: the optimum and an optimal assignment (stated as THE assignment only when unique).

\[\min_{\sigma} \sum_i c_{i\sigma(i)} = \max \Big\{ \sum_i u_i + \sum_j v_j : u_i + v_j \le c_{ij} \Big\}\]
inputmeaningcondition
Cvalue matrix, rows = workers, columns = tasks (square)
outputmeaning
max_valueoptimal total value
assignmentcolumn assigned to each row, 1-based (only when unique; otherwise assignment_example)
assignment_uniqueyes when the optimal assignment is unique
dual_urow potentials
dual_vcolumn potentials (u_i + v_j bounds every cell: the optimality certificate)
Assignment problem (Hungarian method), maximum total value: column assigned to each row, 1-based (only when…column assigned to each row, 1-based (only when unique; otherwise assignment_example) (assignment) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 3, last 2, largest 3); with dual_u (row potentials), dual_v (column potentials (u_i + v_j bounds every cell: the optimality certificate)). Inputs: C = 9 2 7; 6 4 3; 5 8 1.12302468assignment — column assigned to each row, 1-dual_u — row potentialsdual_v — column potentials (u_i + v_j boundsposition in the listassignment — column assigned to each row
column assigned to each row, 1-based (only when unique; otherwise assignment_example) (assignment) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 3, last 2, largest 3); with dual_u (row potentials), dual_v (column potentials (u_i + v_j bounds every cell: the optimality certificate)). Inputs: C = 9 2 7; 6 4 3; 5 8 1.
Assignment problem (Hungarian method), maximum total value: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): C (input); assignment (returned). Returned with them by optimization-ai999x: max_value = 21.927643581123123C (input)312123assignment (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): C (input); assignment (returned). Returned with them by optimization-ai999x: max_value = 21.
optimization_ai999x.solve('assignment_max_profit', C='9 2 7; 6 4 3; 5 8 1')
# -> max_value = 21, assignment = [3, 1, 2], assignment_unique = yes, dual_u = [7.0, 4.0, 8.0], dual_v = [2.0, 0.0, 0.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the assignment problem to maximize total profit with matrix [[9, 2, 7], [6, 4, 3], [5, 8, 1]].SOLVEDmax_value = 21, assignment = [3, 1, 2], assignment_unique = yes, dual_u = [7.0, 4.0, 8.0], dual_v = [2.0, 0.0, 0.0]
Solve the assignment problem to maximize total profit with matrix [[9, 2, 7], [6, 4, 3]].INVALID_INPUTAssignment problem (Hungarian method), maximum total value: give a square matrix with at most 12 rows (add dummy rows or

Maximum bipartite matching — bipartite_matching

The largest number of pairs that can be formed between two groups (workers and jobs, students and projects) using only allowed pairs, with one maximum matching and a vertex cover proving it maximum.

\[\nu(G) = \tau(G) \text{ for bipartite } G\]
inputmeaningcondition
edgesallowed pairs 'left-right', e.g. '$W_{1}-J_{1}$, $W_{1}-J_{2}$, $W_{2}-J_{1}$'
outputmeaning
max_matchingsize of a maximum matching
matching_exampleone maximum matching
vertex_covera minimum vertex cover of the same size (Konig's theorem: the certificate)
Maximum bipartite matching: the networkThe network edges (allowed pairs 'left-right', e.g. 'W1-J1, W1-J2, W2-J1') of the worked example (6 nodes, 5 edges, laid out on a circle); highlighted: the returned path W1 → W2 → W3. Returned: max_matching = 3.W1J1J2W2W3J3
The network edges (allowed pairs 'left-right', e.g. 'W1-J1, W1-J2, W2-J1') of the worked example (6 nodes, 5 edges, laid out on a circle); highlighted: the returned path W1 → W2 → W3. Returned: max_matching = 3.
optimization_ai999x.solve('bipartite_matching', edges='W1-J1, W1-J2, W2-J1, W3-J2, W3-J3')
# -> max_matching = 3, matching_example = ['W1-J2', 'W2-J1', 'W3-J3'], vertex_cover = ['W1', 'W2', 'W3']   (SOLVED)
optimization_ai999x.solve('bipartite_matching', edges='A-X, B-X, C-X')
# -> max_matching = 1, matching_example = ['A-X'], vertex_cover = ['X']   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the maximum bipartite matching with edges W1-J1, W1-J2, W2-J1, W3-J2, W3-J3.SOLVEDmax_matching = 3, matching_example = ['W1-J2', 'W2-J1', 'W3-J3'], vertex_cover = ['W1', 'W2', 'W3']

Maximum-weight matching (general graph) — max_weight_matching

Pair up nodes of a graph (each node at most once) so that the total weight of the chosen edges is as large as possible: the maximum weight and one optimal matching.

\[\max_{M \text{ matching}} \sum_{e \in M} w_e\]
inputmeaningcondition
edgesundirected weighted edges 'A-B 4, ...'
outputmeaning
max_weightmaximum total weight of a matching
matching_exampleone maximum-weight matching
Maximum-weight matching (general graph): the networkThe network edges (undirected weighted edges 'A-B 4, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: max_weight = 12.65624ABCD
The network edges (undirected weighted edges 'A-B 4, ...') of the worked example (4 nodes, 5 edges, laid out on a circle); on each edge its stated weight. Returned: max_weight = 12.
optimization_ai999x.solve('max_weight_matching', edges='A-B 6, B-C 5, C-D 6, A-D 2, A-C 4')
# -> max_weight = 12, matching_example = ['A-B', 'C-D']   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the maximum weight matching of the graph with edges A-B 6, B-C 5, C-D 6, A-D 2, A-C 4.SOLVEDmax_weight = 12, matching_example = ['A-B', 'C-D']

Travelling salesman tour (exact, Held-Karp) — traveling_salesman

The shortest round trip visiting every city exactly once and returning to the start, for a distance matrix (symmetric or not): the minimum tour length and one optimal tour.

\[g(S, k) = \min_{m \in S \setminus \{k\}} \big(g(S \setminus \{k\}, m) + d_{mk}\big)\]
inputmeaningcondition
Ddistance matrix, D[i][j] = distance from city i to city j
outputmeaning
min_tour_lengthlength of a shortest tour
tour_exampleone optimal tour starting and ending at city 1
Travelling salesman tour (exact, Held-Karp): one optimal tour starting and ending at city 1one optimal tour starting and ending at city 1 (tour_example) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 1, last 1, largest 4). Inputs: D = [[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0….1234501234position in the listtour_example
one optimal tour starting and ending at city 1 (tour_example) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 1, last 1, largest 4). Inputs: D = [[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0….
Travelling salesman tour (exact, Held-Karp): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): D (input). Returned with them by optimization-ai999x: min_tour_length = 80.010152010035251535030202530012341234D (input)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): D (input). Returned with them by optimization-ai999x: min_tour_length = 80.
optimization_ai999x.solve('traveling_salesman', D=[[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0]])
# -> min_tour_length = 80, tour_example = [1, 3, 4, 2, 1]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the travelling salesman problem with distance matrix [[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0]].SOLVEDmin_tour_length = 80, tour_example = [1, 3, 4, 2, 1]

0/1 knapsack problem — knapsack_01

Choose items (each at most once) to maximise total value without exceeding the capacity: the maximum value, one optimal choice and its weight.

\[\max \sum_i v_i x_i \ \text{s.t.}\ \sum_i w_i x_i \le W,\ x_i \in \{0,1\}\]
inputmeaningcondition
valuesvalue of each item
weightsweight of each item
capacityknapsack capacity
outputmeaning
max_valuemaximum total value
items_exampleone optimal set of items (1-based; ties to the lighter set)
total_weightweight of that set
0/1 knapsack problem: maximum total value against knapsack capacitymax_value (maximum total value) against capacity (knapsack capacity) from 5 to 500 on a logarithmic axis. Other inputs as in the worked example: values = 60, 100, 120, weights = 10, 20, 30. 41 points computed by optimization-ai999x; marked: the worked example, capacity = 50, max_value = 220.101000100200300220capacity — knapsack capacitymax_value — maximum total value
max_value (maximum total value) against capacity (knapsack capacity) from 5 to 500 on a logarithmic axis. Other inputs as in the worked example: values = 60, 100, 120, weights = 10, 20, 30. 41 points computed by optimization-ai999x; marked: the worked example, capacity = 50, max_value = 220.
optimization_ai999x.solve('knapsack_01', values='60, 100, 120', weights='10, 20, 30', capacity=50)
# -> max_value = 220, items_example = [2, 3], total_weight = 50   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the knapsack problem with values [60, 100, 120], weights [10, 20, 30] and capacity 50.SOLVEDmax_value = 220, items_example = [2, 3], total_weight = 50
Solve the knapsack problem with values [60, 100, 120], weights [10, 20, 30] and capacity 50; items cannot be repeated.SOLVEDmax_value = 220, items_example = [2, 3], total_weight = 50

Unbounded knapsack problem — knapsack_unbounded

Choose any number of copies of each item type to maximise total value within the capacity.

\[V(c) = \max\big(V(c-1),\ \max_{i: w_i \le c} V(c - w_i) + v_i\big)\]
inputmeaningcondition
valuesvalue of each item type
weightsweight of each item type (whole numbers)
capacitycapacity (a whole number)
outputmeaning
max_valuemaximum total value
copies_examplenumber of copies of each type in one optimal choice
Unbounded knapsack problem: number of copies of each type in one optimal choicenumber of copies of each type in one optimal choice (copies_example) returned by optimization-ai999x for the worked example, one value for each values (value of each item type) (4 values, first 0, last 1, largest 1). Inputs: values = [10, 40, 50, 70], weights = [1, 3, 4, 5], capacity = 8.20406000.250.50.751values — value of each item typecopies_example
number of copies of each type in one optimal choice (copies_example) returned by optimization-ai999x for the worked example, one value for each values (value of each item type) (4 values, first 0, last 1, largest 1). Inputs: values = [10, 40, 50, 70], weights = [1, 3, 4, 5], capacity = 8.
Unbounded knapsack problem: maximum total value against capacity (a whole number)max_value (maximum total value) against capacity (capacity (a whole number)) from 1 to 16. Other inputs as in the worked example: values = [10, 40, 50, 70], weights = [1, 3, 4, 5]. 16 points computed by optimization-ai999x; marked: the worked example, capacity = 8, max_value = 110.510150100200110capacity — capacity (a whole number)max_value — maximum total value
max_value (maximum total value) against capacity (capacity (a whole number)) from 1 to 16. Other inputs as in the worked example: values = [10, 40, 50, 70], weights = [1, 3, 4, 5]. 16 points computed by optimization-ai999x; marked: the worked example, capacity = 8, max_value = 110.
optimization_ai999x.solve('knapsack_unbounded', values=[10, 40, 50, 70], weights=[1, 3, 4, 5], capacity=8)
# -> max_value = 110, copies_example = [0.0, 1.0, 0.0, 1.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the unbounded knapsack problem with values [10, 40, 50, 70], weights [1, 3, 4, 5] and capacity 8.SOLVEDmax_value = 110, copies_example = [0.0, 1.0, 0.0, 1.0]

Minimum-cost set cover — set_cover

Choose sets (each with a cost) that together contain every element, at least total cost.

\[\min \sum_i c_i x_i\ \text{s.t.}\ \sum_{i \ni e} x_i \ge 1\ \forall e,\ x \in \{0,1\}\]
inputmeaningcondition
setsincidence matrix: row i lists with $0/1$ which elements set i contains
costscost of each set
outputmeaning
min_costminimum total cost of a cover
sets_exampleone optimal choice of sets (1-based)
Minimum-cost set cover: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): sets (input). Returned with them by optimization-ai999x: min_cost = 4. Other inputs: costs = [3, 2, 3, 2].110001100011100112341234sets (input)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): sets (input). Returned with them by optimization-ai999x: min_cost = 4. Other inputs: costs = [3, 2, 3, 2].
optimization_ai999x.solve('set_cover', sets=[[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]], costs=[3, 2, 3, 2])
# -> min_cost = 4, sets_example = [2, 4]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the set cover problem with incidence matrix [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1], [1, 0, 0, 1]] and costs [3, 2, 3, 2].SOLVEDmin_cost = 4, sets_example = [2, 4]

Uncapacitated facility location — facility_location

Choose which facilities to open (each with a fixed cost) and serve every customer from its cheapest open facility, minimising fixed plus service cost.

\[\min_{S \neq \emptyset} \sum_{i \in S} f_i + \sum_j \min_{i \in S} c_{ij}\]
inputmeaningcondition
fixedfixed opening cost of each facility
costservice cost matrix, rows = facilities, columns = customers
outputmeaning
min_costminimum total cost
open_exampleone optimal set of facilities to open (1-based)
Uncapacitated facility location: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): cost (input). Returned with them by optimization-ai999x: min_cost = 31. Other inputs: fixed = [10, 15, 12].3869724356281231234cost (input)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): cost (input). Returned with them by optimization-ai999x: min_cost = 31. Other inputs: fixed = [10, 15, 12].
optimization_ai999x.solve('facility_location', fixed=[10, 15, 12], cost=[[3, 8, 6, 9], [7, 2, 4, 3], [5, 6, 2, 8]])
# -> min_cost = 31, open_example = [2]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Facility location: fixed costs [10, 15, 12] and service cost matrix [[3, 8, 6, 9], [7, 2, 4, 3], [5, 6, 2, 8]]. Which facilities should open?SOLVEDmin_cost = 31, open_example = [2]

Bin packing (minimum number of bins) — bin_packing

Pack items of given sizes into the fewest bins of a given capacity: the minimum number and one packing.

\[\min \#\text{bins} \ \ge\ \left\lceil \sum_j s_j / C \right\rceil\]
inputmeaningcondition
sizessize of each item
capacitycapacity of each bin
outputmeaning
min_binsminimum number of bins
bin_of_itemone optimal packing: bin number of each item
lower_boundceil(total size / capacity)
Bin packing (minimum number of bins): one optimal packing: bin number of each itemone optimal packing: bin number of each item (bin_of_item) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 2, last 2, largest 2). Inputs: sizes = [4, 8, 1, 4, 2, 1], capacity = 10.24600.511.52position in the listbin_of_item
one optimal packing: bin number of each item (bin_of_item) returned by optimization-ai999x for the worked example, one value for each position in the list (6 values, first 2, last 2, largest 2). Inputs: sizes = [4, 8, 1, 4, 2, 1], capacity = 10.
Bin packing (minimum number of bins): minimum number of bins against capacity of each binmin_bins (minimum number of bins) against capacity (capacity of each bin) from 5 to 15. Other inputs as in the worked example: sizes = [4, 8, 1, 4, 2, 1]. 22 points computed by optimization-ai999x; marked: the worked example, capacity = 10, min_bins = 2.810121422.252.52.7532capacity — capacity of each binmin_bins — minimum number of bins
min_bins (minimum number of bins) against capacity (capacity of each bin) from 5 to 15. Other inputs as in the worked example: sizes = [4, 8, 1, 4, 2, 1]. 22 points computed by optimization-ai999x; marked: the worked example, capacity = 10, min_bins = 2.
optimization_ai999x.solve('bin_packing', sizes=[4, 8, 1, 4, 2, 1], capacity=10)
# -> min_bins = 2, bin_of_item = [2, 1, 2, 2, 1, 2], lower_bound = 2   (SOLVED)
optimization_ai999x.solve('bin_packing', sizes=[6, 6, 6], capacity=10)
# -> min_bins = 3, bin_of_item = [1, 2, 3], lower_bound = 2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Bin packing: item sizes [4, 8, 1, 4, 2, 1] and bin capacity 10. Find the minimum number of bins.SOLVEDmin_bins = 2, bin_of_item = [2, 1, 2, 2, 1, 2], lower_bound = 2

Two-person zero-sum game (value and optimal mixed strategies) — zero_sum_game

The value of a matrix game (row player maximises the payoff in the matrix, column player minimises it) and one optimal mixed strategy for each player.

\[v = \max_{x \in \Delta_m} \min_{j} \sum_i x_i a_{ij} = \min_{y \in \Delta_n} \max_i \sum_j a_{ij} y_j\]
inputmeaningcondition
Apayoff matrix to the row player, rows = row strategies, columns = column strategies
outputmeaning
valuevalue of the game
row_strategy_exampleone optimal mixed strategy of the row player
col_strategy_exampleone optimal mixed strategy of the column player
Two-person zero-sum game (value and optimal mixed strategies): one optimal mixed strategy of the row playerone optimal mixed strategy of the row player (row_strategy_example) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.6, last 0, largest 0.6); with col_strategy_example (one optimal mixed strategy of the column player). Inputs: A = [[3, -1, 2], [-2, 4, 1], [0, 1, -1]].12300.20.40.6row_strategy_example — one optimal mixed strcol_strategy_example — one optimal mixed strposition in the listrow_strategy_example
one optimal mixed strategy of the row player (row_strategy_example) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.6, last 0, largest 0.6); with col_strategy_example (one optimal mixed strategy of the column player). Inputs: A = [[3, -1, 2], [-2, 4, 1], [0, 1, -1]].
Two-person zero-sum game (value and optimal mixed strategies): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); row_strategy_example (returned). Returned with them by optimization-ai999x: value = 1.3-12-24101-1123123A (input)0.60.40123row_strategy_example (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); row_strategy_example (returned). Returned with them by optimization-ai999x: value = 1.
optimization_ai999x.solve('zero_sum_game', A=[[3, -1, 2], [-2, 4, 1], [0, 1, -1]])
# -> value = 1, row_strategy_example = [0.6, 0.4, 0.0], col_strategy_example = [0.5, 0.5, 0.0]   (SOLVED)
optimization_ai999x.solve('zero_sum_game', A=[[1, -1], [-1, 1]])
# -> value = 0, row_strategy_example = [0.5, 0.5], col_strategy_example = [0.5, 0.5]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the zero-sum game with payoff matrix [[3, -1, 2], [-2, 4, 1], [0, 1, -1]].SOLVEDvalue = 1, row_strategy_example = [0.6, 0.4, 0.0], col_strategy_example = [0.5, 0.5, 0.0]
Solve the zero-sum game with payoff matrix [[3, -1, 2], [-2, 4]].INVALID_INPUTA: expected a rectangular matrix (rows of equal length).

2 x 2 zero-sum game (saddle point or mixed-strategy formula) — zero_sum_2x2

The value of a 2 x 2 matrix game: the saddle-point value when one exists, otherwise the mixed-strategy solution (probability of each player's first strategy, unique in that case).

\[v = \frac{ad - bc}{a + d - b - c},\quad p = \frac{d - c}{a + d - b - c},\quad q = \frac{d - b}{a + d - b - c}\]
inputmeaningcondition
A2 x 2 payoff matrix to the row player [[a, b], [c, d]]
outputmeaning
valuevalue of the game
saddle_pointyes when a pure saddle point exists
p_row1probability the row player plays row 1 (only without a saddle point)
q_col1probability the column player plays column 1 (only without a saddle point)
2 x 2 zero-sum game (saddle point or mixed-strategy formula): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input). Returned with them by optimization-ai999x: value = 1, p_row1 = 0.6, q_col1 = 0.5.3-1-241212A (input)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input). Returned with them by optimization-ai999x: value = 1, p_row1 = 0.6, q_col1 = 0.5.
optimization_ai999x.solve('zero_sum_2x2', A=[[3, -1], [-2, 4]])
# -> value = 1, p_row1 = 0.6, q_col1 = 0.5, saddle_point = no   (SOLVED)
optimization_ai999x.solve('zero_sum_2x2', A=[[4, 2], [1, 3]])
# -> value = 2.5, p_row1 = 0.5, q_col1 = 0.25, saddle_point = no   (SOLVED)
optimization_ai999x.solve('zero_sum_2x2', A=[[5, 3], [4, 1]])
# -> value = 3, saddle_point = yes   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the zero-sum game with payoff matrix [[3, -1], [-2, 4]].SOLVEDvalue = 1, p_row1 = 0.6, q_col1 = 0.5, saddle_point = no
Solve the zero-sum game with payoff matrix [[5, 3], [4, 1]].SOLVEDvalue = 3, saddle_point = yes

Pure-strategy Nash equilibria of a bimatrix game — pure_nash_equilibria

Every pure-strategy Nash equilibrium (a cell where each player's strategy is a best reply to the other's) of a two-player game given by the two players' payoff matrices.

\[a_{rs} = \max_k a_{ks},\quad b_{rs} = \max_k b_{rk}\]
inputmeaningcondition
Arow player's payoffs (rows = row strategies)
Bcolumn player's payoffs (same shape)
outputmeaning
countnumber of pure equilibria
equilibriaall pure equilibria as [row, column], 1-based, in row-major order
Pure-strategy Nash equilibria of a bimatrix game: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); B (input); equilibria (returned). Returned with them by optimization-ai999x: count = 1.30511212A (input)35011212B (input)2212equilibria (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); B (input); equilibria (returned). Returned with them by optimization-ai999x: count = 1.
optimization_ai999x.solve('pure_nash_equilibria', A=[[3, 0], [5, 1]], B=[[3, 5], [0, 1]])
# -> count = 1, equilibria = [[2.0, 2.0]]   (SOLVED)
optimization_ai999x.solve('pure_nash_equilibria', A=[[2, 0], [0, 1]], B=[[1, 0], [0, 2]])
# -> count = 2, equilibria = [[1.0, 1.0], [2.0, 2.0]]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the pure-strategy Nash equilibria of the bimatrix game with row payoffs [[3, 0], [5, 1]] and column payoffs [[3, 5], [0, 1]].SOLVEDcount = 1, equilibria = [[2.0, 2.0]]
Find the pure-strategy Nash equilibria of the bimatrix game with row payoffs [[3, 0], [5, 1]] and column payoffs [[3, 5, 1], [0, 1, 2]].INVALID_INPUTPure-strategy Nash equilibria of a bimatrix game: the row and column payoff matrices must have the same shape.

Mixed-strategy Nash equilibrium of a 2 x 2 game — mixed_nash_2x2

The equilibrium of a 2 x 2 two-player game without a pure equilibrium: each player's probability of the first strategy (chosen to make the OTHER player indifferent) and the expected payoffs.

\[q = \frac{a_{22} - a_{12}}{a_{11} - a_{12} - a_{21} + a_{22}},\quad p = \frac{b_{22} - b_{21}}{b_{11} - b_{12} - b_{21} + b_{22}}\]
inputmeaningcondition
Arow player's 2 x 2 payoffs
Bcolumn player's 2 x 2 payoffs
outputmeaning
p_row1probability the row player plays row 1
q_col1probability the column player plays column 1
row_payoffrow player's expected payoff
col_payoffcolumn player's expected payoff
Mixed-strategy Nash equilibrium of a 2 x 2 game: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); B (input). Returned with them by optimization-ai999x: p_row1 = 0.4, q_col1 = 0.285714, row_payoff = 0.142857, col_payoff = 0.2.3-1-211212A (input)-121-11212B (input)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): A (input); B (input). Returned with them by optimization-ai999x: p_row1 = 0.4, q_col1 = 0.285714, row_payoff = 0.142857, col_payoff = 0.2.
optimization_ai999x.solve('mixed_nash_2x2', A=[[3, -1], [-2, 1]], B=[[-1, 2], [1, -1]])
# -> p_row1 = 0.4, q_col1 = 0.285714, row_payoff = 0.142857, col_payoff = 0.2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the mixed-strategy Nash equilibrium of the game with row payoffs [[3, -1], [-2, 1]] and column payoffs [[-1, 2], [1, -1]].SOLVEDp_row1 = 0.4, q_col1 = 0.285714, row_payoff = 0.142857, col_payoff = 0.2
Find the mixed-strategy Nash equilibrium of the game with row payoffs [[3, 0], [5, 1]] and column payoffs [[3, 5], [0, 1]].INVALID_INPUTMixed-strategy Nash equilibrium of a 2 x 2 game: the game has a pure-strategy equilibrium: its mixed equilibrium is not

TOPSIS ranking (closeness to the ideal solution) — topsis

Rank alternatives scored on several criteria by their relative closeness to the ideal and distance from the anti-ideal solution (vector normalisation, weighted Euclidean distances).

\[C_i = \frac{D_i^-}{D_i^+ + D_i^-},\quad D_i^\pm = \Big\| w \odot r_i - v^\pm \Big\|_2\]
inputmeaningcondition
Xdecision matrix, rows = alternatives, columns = criteria (all values > 0)
wcriterion weights (> 0; normalised to sum 1)
typescriterion types: 1 = benefit (larger is better), -1 = cost (smaller is better)
outputmeaning
scoresscore of each alternative
best_scorethe highest score
bestbest alternative, 1-based (on a tie the first listed)
TOPSIS ranking (closeness to the ideal solution): score of each alternativescore of each alternative (scores) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 0.534277, last 0.401046, largest 0.691632). Inputs: X = [[250, 16, 12, 5], [200, 16, 8, 3], [300, 32…, w = [0.25, 0.25, 0.25, 0.25], types = [-1, 1, 1, 1].1234500.20.40.6position in the listscores — score of each alternative
score of each alternative (scores) returned by optimization-ai999x for the worked example, one value for each position in the list (5 values, first 0.534277, last 0.401046, largest 0.691632). Inputs: X = [[250, 16, 12, 5], [200, 16, 8, 3], [300, 32…, w = [0.25, 0.25, 0.25, 0.25], types = [-1, 1, 1, 1].
TOPSIS ranking (closeness to the ideal solution): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.691632, best = 3. Other inputs: w = [0.25, 0.25, 0.25, 0.25], types = [-1, 1, 1, 1].25016125200168330032164275328422516162123451234X (input)0.53430.30840.69160.53470.40112345scores (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.691632, best = 3. Other inputs: w = [0.25, 0.25, 0.25, 0.25], types = [-1, 1, 1, 1].
optimization_ai999x.solve('topsis', X=[[250, 16, 12, 5], [200, 16, 8, 3], [300, 32, 16, 4], [275, 32, 8, 4], [225, 16, 16, 2]], w=[0.25, 0.25, 0.25, 0.25], types=[-1, 1, 1, 1])
# -> scores = [0.5342768571821003, 0.3083677687324685, 0.6916322312675315, 0.534736584486838, 0.40104612151678615], best_score = 0.691632, best = 3   (SOLVED)
optimization_ai999x.solve('topsis', X=[[1, 1], [2, 2]], w=[1, 1], types=[1, 1])
# -> scores = [0.0, 1.0], best_score = 1, best = 2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Rank with TOPSIS the alternatives with decision matrix [[1, 1], [2, 2]], weights [1, 1] and criteria types [1, 1].SOLVEDscores = [0.0, 1.0], best_score = 1, best = 2
Rank with TOPSIS the alternatives with decision matrix [[1, 1], [2, 2]], weights [1, 1] and criteria types [1, 2].INVALID_INPUTTOPSIS ranking (closeness to the ideal solution): criterion types are 1 (benefit: larger is better) or -1 (cost: smaller

Weighted sum model (simple additive weighting) — weighted_sum_model

Score alternatives by the weighted sum of linearly normalised criterion values (benefit x / max, cost min / x) and pick the best.

\[S_i = \sum_j w_j n_{ij},\quad n_{ij} = \frac{x_{ij}}{\max_i x_{ij}}\ \text{or}\ \frac{\min_i x_{ij}}{x_{ij}}\]
inputmeaningcondition
Xdecision matrix, rows = alternatives, columns = criteria (all values > 0)
wcriterion weights (> 0; normalised to sum 1)
typescriterion types: 1 = benefit (larger is better), -1 = cost (smaller is better)
outputmeaning
scoresscore of each alternative
best_scorethe highest score
bestbest alternative, 1-based (on a tie the first listed)
Weighted sum model (simple additive weighting): score of each alternativescore of each alternative (scores) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.695, last 0.866667, largest 0.866667). Inputs: X = [[250, 16, 12], [200, 16, 8], [300, 32, 16]], w = [0.4, 0.3, 0.3], types = [-1, 1, 1].12300.250.50.75position in the listscores — score of each alternative
score of each alternative (scores) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.695, last 0.866667, largest 0.866667). Inputs: X = [[250, 16, 12], [200, 16, 8], [300, 32, 16]], w = [0.4, 0.3, 0.3], types = [-1, 1, 1].
Weighted sum model (simple additive weighting): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.866667, best = 3. Other inputs: w = [0.4, 0.3, 0.3], types = [-1, 1, 1].25016122001683003216123123X (input)0.6950.70.8667123scores (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.866667, best = 3. Other inputs: w = [0.4, 0.3, 0.3], types = [-1, 1, 1].
optimization_ai999x.solve('weighted_sum_model', X=[[250, 16, 12], [200, 16, 8], [300, 32, 16]], w=[0.4, 0.3, 0.3], types=[-1, 1, 1])
# -> scores = [0.6950000000000001, 0.7, 0.8666666666666667], best_score = 0.866667, best = 3   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Score with the weighted sum model the alternatives with decision matrix [[250, 16, 12], [200, 16, 8], [300, 32, 16]], weights [0.4, 0.3, 0.3] and criteria types [-1, 1, 1].SOLVEDscores = [0.6950000000000001, 0.7, 0.8666666666666667], best_score = 0.866667, best = 3

Weighted product model — weighted_product_model

Score alternatives by the product of linearly normalised criterion values raised to the criterion weights.

\[P_i = \prod_j n_{ij}^{\,w_j}\]
inputmeaningcondition
Xdecision matrix, rows = alternatives, columns = criteria (all values > 0)
wcriterion weights (> 0; normalised to sum 1)
typescriterion types: 1 = benefit (larger is better), -1 = cost (smaller is better)
outputmeaning
scoresscore of each alternative
best_scorethe highest score
bestbest alternative, 1-based (on a tie the first listed)
Weighted product model: the vectorsThe plane vectors of the worked example as arrows from the origin: input w = (0.5, 0.5), types = (1, 1); returned by optimization-ai999x: scores = (0.707107, 0.707107); also returned best_score = 0.707107, best = 1. Other inputs: X = [[4, 2], [2, 4]]. Marked: the tip of each returned vector.00.5100.250.50.751w = (0.5, 0.5) (input)types = (1, 1) (input)scores = (0.707107, 0.707107) (returned)xy
The plane vectors of the worked example as arrows from the origin: input w = (0.5, 0.5), types = (1, 1); returned by optimization-ai999x: scores = (0.707107, 0.707107); also returned best_score = 0.707107, best = 1. Other inputs: X = [[4, 2], [2, 4]]. Marked: the tip of each returned vector.
Weighted product model: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.707107, best = 1. Other inputs: w = [0.5, 0.5], types = [1, 1].42241212X (input)0.70710.707112scores (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): X (input); scores (returned). Returned with them by optimization-ai999x: best_score = 0.707107, best = 1. Other inputs: w = [0.5, 0.5], types = [1, 1].
optimization_ai999x.solve('weighted_product_model', X=[[4, 2], [2, 4]], w=[0.5, 0.5], types=[1, 1])
# -> scores = [0.7071067811865476, 0.7071067811865476], best_score = 0.707107, best = 1   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Score with the weighted product model the alternatives with decision matrix [[4, 2], [2, 4]], weights [0.5, 0.5] and criteria types [1, 1].SOLVEDscores = [0.7071067811865476, 0.7071067811865476], best_score = 0.707107, best = 1

AHP priority vector (principal eigenvector) — ahp_priority_vector

The priority weights of criteria compared in pairs (analytic hierarchy process): the normalised principal eigenvector of the reciprocal comparison matrix, and its eigenvalue lambda_max.

\[P w = \lambda_{\max} w,\quad \sum_i w_i = 1\]
inputmeaningcondition
judgmentsupper-triangle pairwise judgments a12, a13, ..., a23, ... (Saaty scale; a_ji = 1/a_ij)
outputmeaning
weightspriority weights (sum 1)
lambda_maxprincipal eigenvalue
besthighest-priority criterion, 1-based
AHP priority vector (principal eigenvector): priority weights (sum 1)priority weights (sum 1) (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].12300.20.40.6position in the listweights — priority weights (sum 1)
priority weights (sum 1) (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].
optimization_ai999x.solve('ahp_priority_vector', judgments=[2, 4, 2])
# -> weights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], lambda_max = 3, best = 1   (SOLVED)
optimization_ai999x.solve('ahp_priority_vector', judgments=[3])
# -> weights = [0.75, 0.25], lambda_max = 2, best = 1   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the AHP priority vector for the pairwise judgments [2, 4, 2].SOLVEDweights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], lambda_max = 3, best = 1
Find the AHP priority vector for the pairwise judgments [2, 4].INVALID_INPUTAHP priority vector (principal eigenvector): give the upper-triangle judgments a12, a13, ..., a1n, a23, ... (3, 6, 10, .

AHP consistency ratio — ahp_consistency_ratio

How consistent a set of pairwise comparisons is: CI = (lambda_max - n)/(n - 1) and $CR = CI / RI$ (Saaty's random index); CR below 0.10 is conventionally acceptable.

\[CI = \frac{\lambda_{\max} - n}{n - 1},\quad CR = \frac{CI}{RI_n}\]
inputmeaningcondition
judgmentsupper-triangle pairwise judgments a12, a13, ..., a23, ... (Saaty scale; a_ji = 1/a_ij)
outputmeaning
CRconsistency ratio
CIconsistency index
lambda_maxprincipal eigenvalue
weightspriority weights
acceptableyes when $CR < 0.10$
AHP consistency ratio: priority weightspriority weights (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].12300.20.40.6position in the listweights — priority weights
priority weights (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].
optimization_ai999x.solve('ahp_consistency_ratio', judgments=[2, 4, 2])
# -> CR = 0, CI = 0, lambda_max = 3, weights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], acceptable = yes   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the AHP consistency ratio for the pairwise judgments [2, 4, 2].SOLVEDCR = 0, CI = 0, lambda_max = 3, weights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], acceptable = yes
Find the AHP consistency ratio for the pairwise judgments [3].INVALID_INPUTAHP consistency ratio: the consistency ratio needs at least 3 criteria.

AHP weights by the geometric mean method — ahp_geometric_mean

Priority weights from pairwise comparisons as normalised row geometric means (the logarithmic least-squares solution).

\[w_i = \frac{(\prod_j a_{ij})^{1/n}}{\sum_k (\prod_j a_{kj})^{1/n}}\]
inputmeaningcondition
judgmentsupper-triangle pairwise judgments a12, a13, ..., a23, ... (Saaty scale; a_ji = 1/a_ij)
outputmeaning
weightspriority weights (sum 1)
max_weightlargest weight
besthighest-priority criterion, 1-based
AHP weights by the geometric mean method: priority weights (sum 1)priority weights (sum 1) (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].12300.20.40.6position in the listweights — priority weights (sum 1)
priority weights (sum 1) (weights) returned by optimization-ai999x for the worked example, one value for each position in the list (3 values, first 0.571429, last 0.142857, largest 0.571429). Inputs: judgments = [2, 4, 2].
optimization_ai999x.solve('ahp_geometric_mean', judgments=[2, 4, 2])
# -> weights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], max_weight = 0.571429, best = 1   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the AHP weights by the geometric mean method for the pairwise judgments [2, 4, 2].SOLVEDweights = [0.5714285714285714, 0.2857142857142857, 0.14285714285714285], max_weight = 0.571429, best = 1

Unconstrained quadratic minimisation — unconstrained_quadratic_min

Minimise f(x) = 1/2 $x^{T}$ Q $x + c^{T}$ x for a symmetric positive definite Q: the minimiser and the minimum.

\[x^* = -Q^{-1} c,\quad f^* = \tfrac12 c^\top x^*\]
inputmeaningcondition
Qsymmetric positive definite Hessian Q (n x n)
clinear term c (n entries)
outputmeaning
f_minminimum value
x_starthe minimiser x* = -Q^{-1} c (unique)
Unconstrained quadratic minimisation: the vectorsThe plane vectors of the worked example as arrows from the origin: input c = (-1, -2); returned by optimization-ai999x: x_star = (0.0909091, 0.636364); also returned f_min = -0.681818. Other inputs: Q = [[4, 1], [1, 3]]. Marked: the tip of each returned vector.-20-2-10c = (-1, -2) (input)x_star = (0.0909091, 0.636364) (returned)xy
The plane vectors of the worked example as arrows from the origin: input c = (-1, -2); returned by optimization-ai999x: x_star = (0.0909091, 0.636364); also returned f_min = -0.681818. Other inputs: Q = [[4, 1], [1, 3]]. Marked: the tip of each returned vector.
Unconstrained quadratic minimisation: the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); x_star (returned). Returned with them by optimization-ai999x: f_min = -0.681818. Other inputs: c = [-1, -2].41131212Q (input)0.090910.636412x_star (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); x_star (returned). Returned with them by optimization-ai999x: f_min = -0.681818. Other inputs: c = [-1, -2].
optimization_ai999x.solve('unconstrained_quadratic_min', Q=[[4, 1], [1, 3]], c=[-1, -2])
# -> f_min = -0.681818, x_star = [0.09090909090909091, 0.6363636363636364]   (SOLVED)
optimization_ai999x.solve('unconstrained_quadratic_min', Q=[[2, 0], [0, 2]], c=[-4, 2])
# -> f_min = -5, x_star = [2.0, -1.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Minimise the unconstrained quadratic with Hessian Q = [[4, 1], [1, 3]] and linear term c = [-1, -2].SOLVEDf_min = -0.681818, x_star = [0.09090909090909091, 0.6363636363636364]
Minimise the unconstrained quadratic with Hessian Q = [[1, 2], [2, 1]] and linear term c = [-1, -2].INVALID_INPUTUnconstrained quadratic minimisation: Q must be positive definite (otherwise there is no unique minimum).

Equality-constrained quadratic program (Lagrange multipliers / KKT) — equality_constrained_qp

Minimise $1/2$ $x^{T}$ Q $x + c^{T}$ x subject to A $x = b$: the minimiser, the minimum and the Lagrange multipliers.

\[\begin{bmatrix} Q & A^\top \\ A & 0 \end{bmatrix}\begin{bmatrix} x \\ \lambda \end{bmatrix} = \begin{bmatrix} -c \\ b \end{bmatrix}\]
inputmeaningcondition
Qsymmetric positive definite Hessian Q
clinear term c
Aconstraint matrix A (rows = constraints)
bright-hand side b
outputmeaning
f_minminimum value
x_starthe minimiser (unique)
multipliersLagrange multipliers lambda (convention Q $x + c + A^{T}$ lambda = 0)
Equality-constrained quadratic program (Lagrange multipliers / KKT): the vectorsThe plane vectors of the worked example as arrows from the origin: input c = (0, 0); returned by optimization-ai999x: x_star = (1, 1); also returned f_min = 2. Other inputs: Q = [[2, 0], [0, 2]], A = [[1, 1]], b = [2]. Marked: the tip of each returned vector.00.5100.250.50.751c = (0, 0) (input)x_star = (1, 1) (returned)xy
The plane vectors of the worked example as arrows from the origin: input c = (0, 0); returned by optimization-ai999x: x_star = (1, 1); also returned f_min = 2. Other inputs: Q = [[2, 0], [0, 2]], A = [[1, 1]], b = [2]. Marked: the tip of each returned vector.
Equality-constrained quadratic program (Lagrange multipliers / KKT): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); A (input); x_star (returned). Returned with them by optimization-ai999x: f_min = 2. Other inputs: c = [0, 0], b = [2].20021212Q (input)1112A (input)1112x_star (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); A (input); x_star (returned). Returned with them by optimization-ai999x: f_min = 2. Other inputs: c = [0, 0], b = [2].
optimization_ai999x.solve('equality_constrained_qp', Q=[[2, 0], [0, 2]], c=[0, 0], A=[[1, 1]], b=[2])
# -> f_min = 2, x_star = [1.0, 1.0], multipliers = [-2.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Minimise the equality-constrained quadratic with Hessian Q = [[2, 0], [0, 2]], linear term c = [0, 0], constraint matrix A = [[1, 1]] and right-hand side b = [2].SOLVEDf_min = 2, x_star = [1.0, 1.0], multipliers = [-2.0]
Minimise the equality-constrained quadratic with Hessian Q = [[2, 0], [0, 2]], linear term c = [0, 0], constraint matrix A = [[1, 1], [2, 2]] and right-hand side b = [2, 4].INVALID_INPUTEquality-constrained quadratic program (Lagrange multipliers / KKT): the constraint rows must be linearly independent.

Steepest descent step with exact line search (quadratic) — steepest_descent_step

One iteration of steepest descent on f(x) = 1/2 $x^{T}$ Q $x + c^{T}$ x from x0: the gradient, the exact step length, the new point and its function value.

\[\alpha = \frac{g^\top g}{g^\top Q g},\quad x_1 = x_0 - \alpha g\]
inputmeaningcondition
Qsymmetric positive definite Hessian Q
clinear term c
x0starting point x0
outputmeaning
alphaexact step length $g^{T}$ $g / g^{T}$ Q g
x1new point $x_{0} - \alpha$ g
f1f at the new point
gradientgradient at x0
Steepest descent zig-zagging to the minimumSteepest descent with exact line search on f(x) = ½ xᵀQx, Q = [[2, 0], [0, 8]], from x₀ = (4, 1): six steps computed by the package, each perpendicular to the level set through its start (f = 20, 7.2, 2.592, 0.93312, 0.335923, 0.120932, 0.0435356); marked: x₆ = (0.186624, 0.046656).-505-202x₆ = (0.186624, 0.046656)x₀level sets f = f(xₖ)steepest-descent iteratesx₁x₂
Steepest descent with exact line search on f(x) = ½ xᵀQx, Q = [[2, 0], [0, 8]], from x₀ = (4, 1): six steps computed by the package, each perpendicular to the level set through its start (f = 20, 7.2, 2.592, 0.93312, 0.335923, 0.120932, 0.0435356); marked: x₆ = (0.186624, 0.046656).
Steepest descent step with exact line search (quadratic): the vectorsThe plane vectors of the worked example as arrows from the origin: input c = (0, 0), x0 = (4, 1); returned by optimization-ai999x: x1 = (2.4, -0.6), gradient = (8, 8); also returned alpha = 0.2, f1 = 7.2. Other inputs: Q = [[2, 0], [0, 8]]. Marked: the tip of each returned vector.051002468c = (0, 0) (input)x0 = (4, 1) (input)x1 = (2.4, -0.6) (returned)gradient = (8, 8) (returned)xy
The plane vectors of the worked example as arrows from the origin: input c = (0, 0), x0 = (4, 1); returned by optimization-ai999x: x1 = (2.4, -0.6), gradient = (8, 8); also returned alpha = 0.2, f1 = 7.2. Other inputs: Q = [[2, 0], [0, 8]]. Marked: the tip of each returned vector.
Steepest descent step with exact line search (quadratic): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); x1 (returned). Returned with them by optimization-ai999x: alpha = 0.2, f1 = 7.2. Other inputs: c = [0, 0], x0 = [4, 1].20081212Q (input)2.4-0.612x1 (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): Q (input); x1 (returned). Returned with them by optimization-ai999x: alpha = 0.2, f1 = 7.2. Other inputs: c = [0, 0], x0 = [4, 1].
optimization_ai999x.solve('steepest_descent_step', Q=[[2, 0], [0, 8]], c=[0, 0], x0=[4, 1])
# -> alpha = 0.2, x1 = [2.4, -0.6], f1 = 7.2, gradient = [8.0, 8.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Take one steepest descent step with exact line search for Hessian Q = [[2, 0], [0, 8]] and linear term c = [0, 0] from x0 = [4, 1].SOLVEDalpha = 0.2, x1 = [2.4, -0.6], f1 = 7.2, gradient = [8.0, 8.0]
Take one steepest descent step with exact line search for Hessian Q = [[2, 0], [0, 8]] and linear term c = [0, 0] from x0 = [0, 0].INVALID_INPUTSteepest descent step with exact line search (quadratic): x0 is already the minimiser (the gradient is zero).

Critical point of a two-variable quadratic and its classification — critical_point_two_variables

For f(x, y) = a $x^{2} + b$ xy + c $y^{2} + d$ x + e $y + f_{0}$: the critical point, its value and whether it is a local minimum, a local maximum or a saddle point (second-derivative test).

\[D = f_{xx} f_{yy} - f_{xy}^2 = 4ac - b^2\]
inputmeaningcondition
acoefficient of $x^{2}$
bcoefficient of xy
ccoefficient of $y^{2}$
dcoefficient of x
ecoefficient of y
f0constant term
outputmeaning
f_valuevalue of f at the critical point
xx of the critical point
yy of the critical point
typelocal minimum, local maximum or saddle point
Critical point of a two-variable quadratic and its classification: where the verdict changes (type)local minimum, local maximum or saddle point (type) over a (coefficient of x^2) from 0.3 to 30 and b (coefficient of xy) from 0.2 to 20 (logarithmic axes): each of the 31 × 21 cells is one run of optimization-ai999x, coloured by the verdict it returned — local minimum: 403 cells, saddle point: 248 cells. Other inputs as in the worked example: c = 1, d = -4, e = 6, f0 = 1. Marked: the worked example, a = 3, b = 2 → local minimum.110110local minimumtype: local minimum (403)type: saddle point (248)a — coefficient of x^2b — coefficient of xy
local minimum, local maximum or saddle point (type) over a (coefficient of x^2) from 0.3 to 30 and b (coefficient of xy) from 0.2 to 20 (logarithmic axes): each of the 31 × 21 cells is one run of optimization-ai999x, coloured by the verdict it returned — local minimum: 403 cells, saddle point: 248 cells. Other inputs as in the worked example: c = 1, d = -4, e = 6, f0 = 1. Marked: the worked example, a = 3, b = 2 → local minimum.
Critical point of a two-variable quadratic and its classification: value of f at the critical point against…f_value (value of f at the critical point) against a (coefficient of x^2) from 1.06444 to 30 on a logarithmic axis. One curve for each value of e (coefficient of y): 6, 3, 12. Other inputs as in the worked example: b = 2, c = 1, d = -4, f0 = 1. 30 points per curve computed by optimization-ai999x; marked: the worked example, a = 3, f_value = -20.5.110-1000-750-500-2500-20.5e = 6 (example)e = 3e = 12a — coefficient of x^2f_value — value of f at the critical point
f_value (value of f at the critical point) against a (coefficient of x^2) from 1.06444 to 30 on a logarithmic axis. One curve for each value of e (coefficient of y): 6, 3, 12. Other inputs as in the worked example: b = 2, c = 1, d = -4, f0 = 1. 30 points per curve computed by optimization-ai999x; marked: the worked example, a = 3, f_value = -20.5.
optimization_ai999x.solve('critical_point_two_variables', a=3, b=2, c=1, d=-4, e=6, f0=1)
# -> f_value = -20.5, x = 2.5, y = -5.5, type = local minimum   (SOLVED)
optimization_ai999x.solve('critical_point_two_variables', a=1, b=0, c=-1)
# -> f_value = 0, x = 0, y = 0, type = saddle point   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find and classify the critical point of f(x, y) = 3x^2 + 2xy + y^2 - 4x + 6y + 1.SOLVEDf_value = -20.5, x = 2.5, y = -5.5, type = local minimum
Find and classify the critical point of f(x, y) = x^2 + 2xy + y^2.INVALID_INPUTCritical point of a two-variable quadratic and its classification: 4ac - b^2 = 0: no isolated critical point (the second

Absolute extrema of a polynomial on a closed interval — polynomial_extrema_interval

The absolute minimum and maximum of a polynomial on [lo, hi] (closed-interval method: endpoints and critical points), and where they are attained.

\[\min_{[a,b]} f = \min\{f(a), f(b), f(c) : f'(c) = 0,\ a < c < b\}\]
inputmeaningcondition
coefficientspolynomial coefficients, highest power first
loleft end of the interval
hiright end of the interval
outputmeaning
min_valueabsolute minimum
max_valueabsolute maximum
argmin_examplea point attaining the minimum (the smallest one on a tie)
argmax_examplea point attaining the maximum (the smallest one on a tie)
Absolute extrema of a polynomial on a closed interval: absolute minimum against left end of the intervalmin_value (absolute minimum) against lo (left end of the interval) from -1.5 to -0.5. Other inputs as in the worked example: coefficients = [1, -3, 0, 2], hi = 3. 31 points computed by optimization-ai999x; marked: the worked example, lo = -1, min_value = -2.-1.5-1.25-1-0.75-0.5-8-6-4-2-2lo — left end of the intervalmin_value — absolute minimum
min_value (absolute minimum) against lo (left end of the interval) from -1.5 to -0.5. Other inputs as in the worked example: coefficients = [1, -3, 0, 2], hi = 3. 31 points computed by optimization-ai999x; marked: the worked example, lo = -1, min_value = -2.
optimization_ai999x.solve('polynomial_extrema_interval', coefficients=[1, -3, 0, 2], lo=-1, hi=3)
# -> min_value = -2, max_value = 2, argmin_example = -1, argmax_example = 0   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the absolute minimum and maximum of the polynomial with coefficients [1, -3, 0, 2] on the interval [-1, 3].SOLVEDmin_value = -2, max_value = 2, argmin_example = -1, argmax_example = 0
Find the absolute minimum and maximum of the polynomial with coefficients [1, -3, 0, 2] on the interval [3, -1].INVALID_INPUTAbsolute extrema of a polynomial on a closed interval: the interval needs lo < hi.

Dynamic lot sizing (Wagner-Whitin) — wagner_whitin_lot_sizing

The cheapest ordering plan for known demands over several periods with a fixed cost per order and a holding cost per unit carried to the next period (no shortages).

\[C_t = \min_{1 \le s \le t} \Big( C_{s-1} + K + h \sum_{u=s}^{t} (u - s)\, d_u \Big)\]
inputmeaningcondition
demanddemand in each period
Ksetup (ordering) cost per order
hholding cost per unit per period
outputmeaning
min_costminimum total setup plus holding cost
order_quantities_exampleone optimal plan: quantity ordered in each period
ordersnumber of orders in that plan
Dynamic lot sizing (Wagner-Whitin): one optimal plan: quantity ordered in each periodone optimal plan: quantity ordered in each period (order_quantities_example) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 80, last 50, largest 80). Inputs: demand = [20, 50, 10, 50], K = 100, h = 1.1234020406080position in the listorder_quantities_example
one optimal plan: quantity ordered in each period (order_quantities_example) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 80, last 50, largest 80). Inputs: demand = [20, 50, 10, 50], K = 100, h = 1.
Dynamic lot sizing (Wagner-Whitin): minimum total setup plus holding cost against setup (ordering) cost per…min_cost (minimum total setup plus holding cost) against K (setup (ordering) cost per order) from 10 to 1000 on a logarithmic axis. One curve for each value of h (holding cost per unit per period): 1, 0.5, 2. Other inputs as in the worked example: demand = [20, 50, 10, 50]. 41 points per curve computed by optimization-ai999x; marked: the worked example, K = 100, min_cost = 270.101001000050010001500270h = 1 (example)h = 0.5h = 2K — setup (ordering) cost per ordermin_cost
min_cost (minimum total setup plus holding cost) against K (setup (ordering) cost per order) from 10 to 1000 on a logarithmic axis. One curve for each value of h (holding cost per unit per period): 1, 0.5, 2. Other inputs as in the worked example: demand = [20, 50, 10, 50]. 41 points per curve computed by optimization-ai999x; marked: the worked example, K = 100, min_cost = 270.
optimization_ai999x.solve('wagner_whitin_lot_sizing', demand=[20, 50, 10, 50], K=100, h=1)
# -> min_cost = 270, order_quantities_example = [80.0, 0.0, 0.0, 50.0], orders = 2   (SOLVED)
optimization_ai999x.solve('wagner_whitin_lot_sizing', demand=[10, 0, 10], K=50, h=5)
# -> min_cost = 100, order_quantities_example = [10.0, 0.0, 10.0], orders = 2   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Wagner-Whitin lot sizing with demands [20, 50, 10, 50], setup cost 100 and holding cost 1 per unit per period.SOLVEDmin_cost = 270, order_quantities_example = [80.0, 0.0, 0.0, 50.0], orders = 2
Wagner-Whitin lot sizing with demands [20, 50, 10, 50] and setup cost 100.NEEDS_INPUTwagner_whitin_lot_sizing needs h (holding cost per unit per period). Example: solve('wagner_whitin_lot_sizing', demand=[

Discounted Markov decision process (optimal values and policy) — mdp_discounted

The optimal expected discounted reward from every state of a finite Markov decision process and an optimal stationary policy.

\[V^*(s) = \max_a \Big( R(s,a) + \gamma \sum_{s'} P(s' \mid s,a)\, V^*(s') \Big)\]
inputmeaningcondition
Rrewards, rows = states, columns = actions
Ttransition probabilities: one row per (state, action) in the order s1a1, s1a2, ..., s2a1, ...; columns = next state
gammadiscount factor $(0 < \gamma < 1)$
outputmeaning
value_state_1optimal value of state 1
valuesoptimal value of every state
policyoptimal action in each state, 1-based (the lowest-numbered one on a tie)
Discounted Markov decision process (optimal values and policy): policy at each valuesoptimal action in each state, 1-based (the lowest-numbered one on a tie) (policy) at each optimal value of every state (values), both returned by optimization-ai999x for the worked example (R = [[1, 0], [0, 2]], T = [[1, 0], [0, 1], [0, 1], [1, 0]], gamma = 0.9): 10 → 1; 11 → 2.1010.210.410.610.81100.511.52(10, 1)(11, 2)values — optimal value of every statepolicy — optimal action in each state
optimal action in each state, 1-based (the lowest-numbered one on a tie) (policy) at each optimal value of every state (values), both returned by optimization-ai999x for the worked example (R = [[1, 0], [0, 2]], T = [[1, 0], [0, 1], [0, 1], [1, 0]], gamma = 0.9): 10 → 1; 11 → 2.
Discounted Markov decision process (optimal values and policy): the matricesThe matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): R (input); T (input); values (returned). Returned with them by optimization-ai999x: value_state_1 = 10. Other inputs: gamma = 0.9.10021212R (input)10010110123412T (input)101112values (returned)
The matrices of the worked example as heatmaps (rows and columns numbered; each cell shaded by its magnitude, negative values in the second colour; each panel shaded by its own largest magnitude): R (input); T (input); values (returned). Returned with them by optimization-ai999x: value_state_1 = 10. Other inputs: gamma = 0.9.
optimization_ai999x.solve('mdp_discounted', R=[[1, 0], [0, 2]], T=[[1, 0], [0, 1], [0, 1], [1, 0]], gamma=0.9)
# -> value_state_1 = 10, values = [10.0, 11.0], policy = [1.0, 2.0]   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Solve the discounted Markov decision process with rewards [[1, 0], [0, 2]], transitions [[1, 0], [0, 1], [0, 1], [1, 0]] and discount factor 0.9.SOLVEDvalue_state_1 = 10, values = [10.0, 11.0], policy = [1.0, 2.0]
Solve the discounted Markov decision process with rewards [[1, 0], [0, 2]], transitions [[1, 0], [0, 1], [0, 1], [1, 0]] and discount factor 1.INVALID_INPUTDiscounted Markov decision process (optimal values and policy): the discount factor must be between 0 and 1 (exclusive).

Chromatic number (minimum graph colouring) — graph_coloring

The fewest colours needed so that adjacent nodes get different colours (scheduling exams, assigning frequencies), and one such colouring.

\[\chi(G) = \min\{k : \exists\, c: V \to \{1..k\},\ c(u) \neq c(v)\ \forall uv \in E\}\]
inputmeaningcondition
edgesedges 'A-B, B-C, ...' (undirected)
outputmeaning
chromatic_numberminimum number of colours
coloring_exampleone optimal colouring, in the order of 'nodes'
nodesnode order (first appearance)
Chromatic number (minimum graph colouring): one optimal colouring, in the order of 'nodes'one optimal colouring, in the order of 'nodes' (coloring_example) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 2, largest 3). Inputs: edges = A-B, B-C, C-A, C-D.12340123position in the listcoloring_example — one optimal colouring
one optimal colouring, in the order of 'nodes' (coloring_example) returned by optimization-ai999x for the worked example, one value for each position in the list (4 values, first 2, last 2, largest 3). Inputs: edges = A-B, B-C, C-A, C-D.
Chromatic number (minimum graph colouring): the networkThe network edges (edges 'A-B, B-C, ...' (undirected)) of the worked example (4 nodes, 4 edges, laid out on a circle); highlighted: the returned path A → B → C → D. Returned: chromatic_number = 3.ABCDreturned path
The network edges (edges 'A-B, B-C, ...' (undirected)) of the worked example (4 nodes, 4 edges, laid out on a circle); highlighted: the returned path A → B → C → D. Returned: chromatic_number = 3.
optimization_ai999x.solve('graph_coloring', edges='A-B, B-C, C-A, C-D')
# -> chromatic_number = 3, coloring_example = [2.0, 3.0, 1.0, 2.0], nodes = ['A', 'B', 'C', 'D']   (SOLVED)
optimization_ai999x.solve('graph_coloring', edges='A-B, B-C, C-D, D-A')
# -> chromatic_number = 2, coloring_example = [1.0, 2.0, 1.0, 2.0], nodes = ['A', 'B', 'C', 'D']   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the chromatic number of the graph with edges A-B, B-C, C-A, C-D.SOLVEDchromatic_number = 3, coloring_example = [2.0, 3.0, 1.0, 2.0], nodes = ['A', 'B', 'C', 'D']
Find the chromatic number of the graph with edges A-A, A-B.INVALID_INPUTChromatic number (minimum graph colouring): a node cannot be joined to itself.

Minimum vertex cover (and maximum independent set) — minimum_vertex_cover

The fewest nodes that touch every edge of a graph (placing guards or sensors), one such set, and the size of a largest set of pairwise non-adjacent nodes.

\[\tau(G) = \min\{|C| : C \cap \{u, v\} \neq \emptyset\ \forall uv \in E\},\quad \alpha(G) = |V| - \tau(G)\]
inputmeaningcondition
edgesedges 'A-B, B-C, ...' (undirected)
outputmeaning
min_cover_sizesize of a minimum vertex cover
cover_exampleone minimum vertex cover
max_independent_set_sizesize of a maximum independent set (nodes minus cover)
Minimum vertex cover (and maximum independent set): the networkThe network edges (edges 'A-B, B-C, ...' (undirected)) of the worked example (5 nodes, 5 edges, laid out on a circle); highlighted: the returned path A → C → E. Returned: min_cover_size = 3, max_independent_set_size = 2.ABCDEreturned path
The network edges (edges 'A-B, B-C, ...' (undirected)) of the worked example (5 nodes, 5 edges, laid out on a circle); highlighted: the returned path A → C → E. Returned: min_cover_size = 3, max_independent_set_size = 2.
optimization_ai999x.solve('minimum_vertex_cover', edges='A-B, A-C, A-D, B-C, D-E')
# -> min_cover_size = 3, cover_example = ['A', 'C', 'E'], max_independent_set_size = 2   (SOLVED)
optimization_ai999x.solve('minimum_vertex_cover', edges='A-B, A-C, A-D')
# -> min_cover_size = 1, cover_example = ['A'], max_independent_set_size = 3   (SOLVED)

Questions in words (documented forms), as executed:

questionoutcomeresult
Find the minimum vertex cover of the graph with edges A-B, A-C, A-D, B-C, D-E.SOLVEDmin_cover_size = 3, cover_example = ['A', 'C', 'E'], max_independent_set_size = 2
Find the minimum vertex cover of the graph with edges A-B, B-B.INVALID_INPUTMinimum vertex cover (and maximum independent set): a node cannot be joined to itself.