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.
a value with its unit, steps, assumptions and verification
use it; read the assumptions
NEEDS_INPUT
a required input is missing; uncertainty['needs'] names it
add it (with its unit) and ask again
AMBIGUOUS
two readings or two physical branches give different answers
say which situation is meant
INVALID_INPUT
a unit of the wrong kind, an unknown input name, values with no valid solution
correct the input
OUT_OF_SCOPE
no certified capability computes this (or the structure is not modelled yet)
see the catalogue below
UNRECOGNIZED_FORMAT
the wording was not recognised; a supported template is offered in uncertainty['try']
use the template or solve()
INTERNAL_ERROR
a defect of the engine, never a property of the question
report it with the question
Result fields
field
meaning
value, unit
the result in SI units
values
every output of a procedure (x1, x2, discriminant ...)
outcome
one of the seven outcomes above
steps
each equation used, its inputs (with where each came from) and its result
assumptions
conditions and declared defaults the answer relies on
verification
residual of every equation, dimensional consistency, independent checks
latex()
the derivation as LaTeX
show()
renders in a notebook, prints in a terminal
Common mistakes
Free wording: if it is not recognised, use the offered template or the structured call; the reader never guesses.
A coefficient that violates a stated condition (a = 0 in a quadratic): INVALID_INPUT says why.
A text value where a number is expected: INVALID_INPUT; fractions as strings ("1/2") are accepted.
A problem outside the procedure (a cubic for the quadratic solver): OUT_OF_SCOPE, never an approximation.
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.
id
operation
inputs
outputs
linear_program
Linear program (simplex method)
sense, c, A, b, relations
optimal_value, x, solution_unique, shadow_prices
lp_two_variable_graphical
Two-variable linear program (graphical corner-point method)
sense, c, A, b, relations
optimal_value, x, y, optimal_corners, corner_points, solution_unique
integer_program
Integer linear program (branch and bound)
sense, c, A, b, relations
optimal_value, x_one_optimal, nodes
lp_shadow_prices
Shadow prices of a linear program
sense, c, A, b, relations
shadow_prices, optimal_value, x, solution_unique
quadratic_optimum
Optimum of a quadratic function
a, b, c, goal
x_opt, f_opt, type
break_even_point
Break-even quantity
F_, p, v
quantity, revenue, contribution_margin
profit_max_linear_demand
Profit-maximising output with linear demand
a, b, cv, F_
quantity, price, profit
revenue_max_linear_demand
Revenue-maximising price with linear demand
alpha, beta
price, quantity, revenue
fence_max_area
Largest rectangle for a given length of fencing
L, wall
width, length, max_area
open_box_max_volume
Open box of maximum volume from a rectangular sheet
L, W
cut, max_volume
can_min_surface
Closed cylinder of least surface area for a given volume
V
radius, height, min_area
eoq
Economic order quantity (EOQ)
D, S, H
Q, total_cost, orders_per_period, cycle_time
eoq_planned_shortages
EOQ with planned backorders
D, S, H, B
Q, max_backorder, max_inventory, total_cost
epq_production_lot
Economic production quantity (EPQ)
D, P, S, H
Q, max_inventory, total_cost, runs_per_period
eoq_quantity_discount
Order quantity with quantity discounts (all-units)
D, S, i_rate, breaks, prices
order_quantity, total_cost, unit_price
reorder_point
Reorder point with safety stock
d, L, sigma, SL
reorder_point, safety_stock, z, lead_time_demand
order_up_to_level
Periodic-review order-up-to level
d, sigma, R, L, SL
order_up_to_level, safety_stock, z
newsvendor_normal
Newsvendor order quantity (normal demand)
p, c, mu, sigma, s
critical_ratio, Q, expected_profit, expected_shortage
newsvendor_uniform
Newsvendor order quantity (uniform demand)
p, c, lo, hi, s
critical_ratio, Q, expected_profit
newsvendor_discrete
Newsvendor order quantity (discrete demand)
p, c, demands, probs, s
critical_ratio, Q, expected_profit
littlewood_protection
Littlewood's rule (two-fare protection level)
p1, p2, mu, sigma, capacity
protection_level, z, booking_limit
mm1_queue
M/M/1 queue
lam, mu
rho, L, Lq, W, Wq, P0
mmc_queue
M/M/c queue (Erlang C)
lam, mu, c
rho, P_wait, Lq, Wq, W, L, P0
mmck_finite_queue
M/M/c/K queue (finite capacity)
lam, mu, c, K
P_block, lam_eff, L, Lq, W, Wq, P0
erlang_b
Erlang B blocking probability (M/M/c/c loss system)
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\]
input
meaning
condition
sense
maximize or minimize
c
objective coefficients, one per variable
A
constraint coefficients, one row per constraint
b
right-hand sides, one per constraint
relations
relation of each constraint: <=, >= or = (default all <=)
output
meaning
optimal_value
optimal value of the objective
x
the optimal solution, variables in order of first appearance (only when unique; otherwise x_one_optimal)
solution_unique
yes when the optimal solution is unique
shadow_prices
change of the optimal value per unit increase of each right-hand side (only when unique; otherwise dual_one_optimal)
Method: two-phase simplex in exact rational arithmetic with Bland's anti-cycling rule; optimality certified by a dual solution (primal feasibility, dual feasibility, equal objective values); uniqueness proved by an auxiliary LP over the optimal face
Assumes: all variables >= 0; the LP is feasible and bounded (otherwise INVALID_INPUT says which); at most 12 variables and constraints
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.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.
Linear 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_INPUT
Linear program (simplex method): the constraints are infeasible: no point satisfies all of them.
Maximize 3x + 5y subject to x + 2y <= 14.
OUT_OF_SCOPE
Out 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\]
input
meaning
condition
sense
maximize or minimize
c
objective coefficients, one per variable
A
constraint coefficients, one row per constraint
b
right-hand sides, one per constraint
relations
relation of each constraint: <=, >= or = (default all <=)
output
meaning
optimal_value
optimal value of the objective
x
first variable at the optimum (only when the optimum is unique)
y
second variable at the optimum (only when the optimum is unique)
optimal_corners
every corner point at which the optimum is attained
corner_points
every corner point of the feasible region
solution_unique
yes when exactly one point is optimal
Method: intersect every pair of boundary lines (exact fractions), keep the feasible corners, evaluate the objective; unboundedness detected from the extreme rays of the recession cone
Assumes: exactly two variables, both >= 0; a feasible region and a finite optimum
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.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].
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.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].
Maximize x + y subject to 2x + 2y = 3, x, y >= 0, integer.
INVALID_INPUT
Integer 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.
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].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].
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.
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.
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.
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.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.
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.
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.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.
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.
An open cylindrical tank must hold 10 m^3. Find the radius that minimizes the surface area.
OUT_OF_SCOPE
Out 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}\]
input
meaning
condition
D
demand per period (units, e.g. per year)
S
fixed cost per order
H
holding cost per unit per period
output
meaning
Q
economic order quantity
total_cost
minimum ordering + holding cost per period
orders_per_period
number of orders per period
cycle_time
time between orders (in periods)
Method: minimise D S / Q + H $Q / 2$ (at the optimum ordering cost equals holding cost)
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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
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_INPUT
Economic 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.
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.
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}\]
input
meaning
condition
d
average demand per period
L
lead time in periods
sigma
standard deviation of demand per period
SL
cycle service level (probability of no stockout per cycle, e.g. 0.95)
output
meaning
reorder_point
reorder point
safety_stock
safety stock z sigma sqrt(L)
z
standard normal quantile of the service level
lead_time_demand
expected demand during the lead time
Method: $z = Phi$^{-1}(SL); ROP = d L + z sigma sqrt(L)
Assumes: $0.5 \leq SL < 1$; independent normal demand per period
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.
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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
SOLVED
order_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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
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.
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.
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.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.
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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
SOLVED
protection_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 (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.
Questions in words (documented forms), as executed:
question
outcome
result
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.
SOLVED
rho = 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?
SOLVED
rho = 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_INPUT
M/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.
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.
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.
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.
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!}\]
input
meaning
condition
A
offered traffic in erlangs (arrival rate x mean holding time)
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.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.
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.
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:
question
outcome
result
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.
SOLVED
L = 1.42434, Lq = 0.709207, lam_eff = 0.715132, W = 1.99171, Wq = 0.991714, P0 = 0.284868, working = 3.57566
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).
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.
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.
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.
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].
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].
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].
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 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].
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.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.
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).
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.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.
Find the critical path: activities have durations [3, 4, 2]; precedences: A-B, B-C, C-A.
INVALID_INPUT
Critical 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).
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.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.
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)\]
input
meaning
condition
edges
weighted edges 'A-B 4, B-C 1, ...'
source
start node
target
end node
directed
true for a directed graph (edge u-v goes from u to v), false for undirected
output
meaning
distance
shortest distance
path
the shortest path (only when unique; otherwise path_example)
path_unique
yes when exactly one shortest path exists
Method: Dijkstra's algorithm in exact arithmetic; shortest paths counted on the tight-edge subgraph
Assumes: weights >= 0; a path from source to target exists; parallel edges: the lightest counts
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).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.
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_INPUT
shortest_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_INPUT
Shortest 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)\]
input
meaning
condition
edges
directed weighted edges 'A-B 4, $B-C -2$, ...'
source
start node
target
end node
output
meaning
distance
shortest distance from source to target
distances_from_source
shortest distance to every reachable node
Method: Bellman-Ford relaxation in exact arithmetic; distances certified as feasible, tight potentials
Assumes: directed graph; no negative cycle reachable from the source (otherwise INVALID_INPUT)
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.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.
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.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.
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).
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.
Find the minimum spanning tree of the graph with edges A-B 4, C-D 1.
INVALID_INPUT
Minimum 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)\]
input
meaning
condition
edges
directed arcs with capacities 'S-A 10, A-T 5, ...'
source
source node
target
sink node
output
meaning
max_flow
maximum flow value
min_cut_source_side
nodes on the source side of a minimum cut (those reachable in the final residual network)
edge_flows
flow on each arc, in input order (one maximum flow)
Method: Edmonds-Karp (breadth-first augmenting paths) in exact arithmetic; certified by the max-flow min-cut theorem
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.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.
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).
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.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]].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].
Solve the transportation problem with supply [5, 5], demand [10, 25, 15] and cost matrix [[2, 3, 1], [5, 4, 8]].
INVALID_INPUT
Transportation 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.
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].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].
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).
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.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.
Solve the assignment problem with cost matrix [[9, 2, 7], [6, 4, 3]].
INVALID_INPUT
Assignment 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).
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.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.
Solve the assignment problem to maximize total profit with matrix [[9, 2, 7], [6, 4, 3]].
INVALID_INPUT
Assignment 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\]
input
meaning
condition
edges
allowed pairs 'left-right', e.g. '$W_{1}-J_{1}$, $W_{1}-J_{2}$, $W_{2}-J_{1}$'
output
meaning
max_matching
size of a maximum matching
matching_example
one maximum matching
vertex_cover
a minimum vertex cover of the same size (Konig's theorem: the certificate)
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.
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\]
input
meaning
condition
edges
undirected weighted edges 'A-B 4, ...'
output
meaning
max_weight
maximum total weight of a matching
matching_example
one maximum-weight matching
Method: exact dynamic programming over node subsets
Assumes: at most 16 nodes; edges of weight <= 0 are never worth choosing
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.
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)\]
input
meaning
condition
D
distance matrix, D[i][j] = distance from city i to city j
output
meaning
min_tour_length
length of a shortest tour
tour_example
one optimal tour starting and ending at city 1
Method: Held-Karp dynamic programming over city subsets, exact arithmetic
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….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.
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.
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.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.
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].
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].
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.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.
payoff matrix to the row player, rows = row strategies, columns = column strategies
output
meaning
value
value of the game
row_strategy_example
one optimal mixed strategy of the row player
col_strategy_example
one optimal mixed strategy of the column player
Method: the game as a pair of dual linear programs on the shifted matrix, solved exactly (rational simplex); the pair of strategies is the certificate (each guarantees the value)
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]].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.
Solve the zero-sum game with payoff matrix [[3, -1, 2], [-2, 4]].
INVALID_INPUT
A: 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}\]
input
meaning
condition
A
2 x 2 payoff matrix to the row player [[a, b], [c, d]]
output
meaning
value
value of the game
saddle_point
yes when a pure saddle point exists
p_row1
probability the row player plays row 1 (only without a saddle point)
q_col1
probability the column player plays column 1 (only without a saddle point)
Method: maximin = minimax gives a saddle point; otherwise the indifference formulas in exact arithmetic
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)
Questions in words (documented forms), as executed:
question
outcome
result
Solve the zero-sum game with payoff matrix [[3, -1], [-2, 4]].
SOLVED
value = 1, p_row1 = 0.6, q_col1 = 0.5, saddle_point = no
Solve the zero-sum game with payoff matrix [[5, 3], [4, 1]].
SOLVED
value = 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.
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.
Questions in words (documented forms), as executed:
question
outcome
result
Find the pure-strategy Nash equilibria of the bimatrix game with row payoffs [[3, 0], [5, 1]] and column payoffs [[3, 5], [0, 1]].
SOLVED
count = 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_INPUT
Pure-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.
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.
Find the mixed-strategy Nash equilibrium of the game with row payoffs [[3, 0], [5, 1]] and column payoffs [[3, 5], [0, 1]].
INVALID_INPUT
Mixed-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).
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].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].
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].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].
Questions in words (documented forms), as executed:
question
outcome
result
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].
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.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].
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.
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].
Find the AHP priority vector for the pairwise judgments [2, 4].
INVALID_INPUT
AHP 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.
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].
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].
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.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].
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.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].
Questions in words (documented forms), as executed:
question
outcome
result
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].
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_INPUT
Equality-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.
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).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.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].
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_INPUT
Steepest 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\]
input
meaning
condition
a
coefficient of $x^{2}$
b
coefficient of xy
c
coefficient of $y^{2}$
d
coefficient of x
e
coefficient of y
f0
constant term
output
meaning
f_value
value of f at the critical point
x
x of the critical point
y
y of the critical point
type
local minimum, local maximum or saddle point
Method: grad $f = 0$ solved exactly; $D = f_xx$ $f_yy - f_xy^{2} = 4ac - b^{2}$ classifies it
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.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:
question
outcome
result
Find and classify the critical point of f(x, y) = 3x^2 + 2xy + y^2 - 4x + 6y + 1.
SOLVED
f_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_INPUT
Critical 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\}\]
input
meaning
condition
coefficients
polynomial coefficients, highest power first
lo
left end of the interval
hi
right end of the interval
output
meaning
min_value
absolute minimum
max_value
absolute maximum
argmin_example
a point attaining the minimum (the smallest one on a tie)
argmax_example
a point attaining the maximum (the smallest one on a tie)
Method: real roots of f' in [lo, hi] (monotone pieces between the roots of f'' bisected to the last float), compared with the endpoints
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.
Find the absolute minimum and maximum of the polynomial with coefficients [1, -3, 0, 2] on the interval [3, -1].
INVALID_INPUT
Absolute 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)\]
input
meaning
condition
demand
demand in each period
K
setup (ordering) cost per order
h
holding cost per unit per period
output
meaning
min_cost
minimum total setup plus holding cost
order_quantities_example
one optimal plan: quantity ordered in each period
orders
number of orders in that plan
Method: Wagner-Whitin dynamic programme (each order covers whole periods) in exact arithmetic
Assumes: demands, K, $h \geq 0$; no initial stock, no shortages, holding charged on end-of-period stock
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.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.
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.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.
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.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.
Find the chromatic number of the graph with edges A-A, A-B.
INVALID_INPUT
Chromatic 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.
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.