Construct and solve continuous linear programs directly in RainbowStats.
Define a model, add linear constraints, set an objective, choose maximization
or minimization, and inspect the resulting allocation, slack, and binding constraints.
Model builderMaximize or minimizeLinear constraintsNonnegative variablesPrimal table
RainbowStats decision variables are nonnegative by default. The symbols
< and > are interpreted and displayed as the
non-strict LP relations ≤ and ≥. Use = for an equality constraint.
Construction workflow
Create an empty model with LINEAR_LP.
Add one linear constraint at a time with ADD_LP_EQUATION.
Set the linear objective with SET_LP_OBJECTIVE.
Solve with MAX_LP or MIN_LP.
Use MODEL_LP and display the LP object to inspect the model.
Mathematical form
A maximization model is written in the standard form:
maximize c′x
subject to Ax ≤ b, Aeqx = beq, x ≥ 0
Every term must remain linear. Products between decision variables,
powers of variables, and nonlinear functions are not valid LP expressions.
Commands
Command
Purpose
Example
LINEAR_LP
Creates a named, initially empty linear-programming model.
LP=LINEAR_LP(TEST)
ADD_LP_EQUATION
Adds a linear inequality or equality to the model.
ADD_LP_EQUATION(LP,X+Y<75)
SET_LP_OBJECTIVE
Defines the linear objective coefficients.
SET_LP_OBJECTIVE(LP,113*X+168*Y)
MAX_LP
Solves the model as a maximization problem.
ANS=MAX_LP(LP)
MIN_LP
Solves the model as a minimization problem.
ANS=MIN_LP(LP)
MODEL_LP
Builds the model presentation after the LP has been solved.
The minimum occurs at X = 0, Y = 10,
with an objective value of 10.
Example: multiperiod capital allocation
This model allocates constrained financing among housing, AI-sensitive
investment, and other private investment over three periods. AI and housing
also face interperiod ramp constraints.
# H = housing, A = AI-sensitive investment, O = other investment
LP=LINEAR_LP(CAPITAL)
ANS=ADD_LP_EQUATION(LP,H1+A1+O1<100)
ANS=ADD_LP_EQUATION(LP,H2+A2+O2<90)
ANS=ADD_LP_EQUATION(LP,H3+A3+O3<80)
ANS=ADD_LP_EQUATION(LP,A1<30)
ANS=ADD_LP_EQUATION(LP,A2<40)
ANS=ADD_LP_EQUATION(LP,A3<50)
ANS=ADD_LP_EQUATION(LP,O1<40)
ANS=ADD_LP_EQUATION(LP,O2<40)
ANS=ADD_LP_EQUATION(LP,O3<40)
ANS=ADD_LP_EQUATION(LP,H1<60)
ANS=ADD_LP_EQUATION(LP,H2<60)
ANS=ADD_LP_EQUATION(LP,H3<60)
ANS=ADD_LP_EQUATION(LP,A2-A1<10)
ANS=ADD_LP_EQUATION(LP,A1-A2<10)
ANS=ADD_LP_EQUATION(LP,A3-A2<10)
ANS=ADD_LP_EQUATION(LP,A2-A3<10)
ANS=ADD_LP_EQUATION(LP,H2-H1<20)
ANS=ADD_LP_EQUATION(LP,H1-H2<20)
ANS=ADD_LP_EQUATION(LP,H3-H2<20)
ANS=ADD_LP_EQUATION(LP,H2-H3<20)
ANS=SET_LP_OBJECTIVE(LP,700*H1+1500*A1+900*O1+679*H2+1455*A2+873*O2+658*H3+1410*A3+846*O3)
ANS=MAX_LP(LP)
LPT=MODEL_LP(LP)
Final_LP=LP
Period
Housing
AI
Other
Financing used
1
30
30
40
100
2
10
40
40
90
3
0
50
30
80
A multiperiod LP is solved once across all periods. Cross-period ramp,
inventory, capital, or project-completion equations make the periods
interdependent rather than separate optimizations.
Reading the result
Field
Meaning
Solution
Optimal value assigned to each decision variable.
Objective
Optimal value of the objective function.
Activity
Left-hand side evaluated at the solution.
Slack
Unused capacity in a nonbinding constraint.
Binding
Indicates that activity equals the constraint boundary.
Shadow
Marginal value of relaxing a constraint, when populated.
Shadow-price check
The marginal value of a capacity constraint can always be verified by
increasing its right-hand side by one unit and solving the model again:
λj = V(bj + 1) − V(bj)
This finite-difference value is valid locally while the optimal basis
remains unchanged. It is especially useful when the displayed
Shadow field is not populated.
Interpretation and limitations
Linear programming finds the best feasible allocation under the stated
coefficients and constraints. It does not estimate the objective returns,
establish causality, or prove that the chosen constraints describe the economy.
Decision variables are continuous. Do not interpret a solution as an
integer or binary decision unless the modeled quantity is naturally divisible.
Nonlinear returns should be represented with capacity-limited linear tranches
or another suitable approximation.