Vars()
[ :x = [0, 40], :y = [0, :integer] ] -- a spec is [lb], [lb, ub], [lb, :integer] or [lb, ub, :integer]. An omitted upper bound means UNBOUNDED ABOVE, which the engine models exactly rather than by a large number standing in for infinity.
Basic examples (2)
oF = new stzOptimModel()
oF.Vars([ :x = [ 0, 10 ] ])
oF.Maximize("x")
oF.SubjectTo([ "x >= 20" ])
oF.Solve()
? oF.StatusWord()infeasible
run on 2026-10-02 04:25 inside the library at commit 0e72e2e2c; taken from 12-an-optimisation-model.en.md(opens in a new tab)
oM = new stzOptimModel()
oM.Vars([ :x = [ 0, 40 ], :y = [ 0, :integer ] ])
oM.Maximize("3*x + 2*y")
oM.SubjectTo([ "x + y <= 50", "2*x + y <= 80" ])
oM.SolveWith(:auto)
? oM.StatusWord()
? oM.Objective()
? @@( oM.Solution() )optimal 130 [ [ "x", 30 ], [ "y", 20 ] ]
run on 2026-10-02 04:25 inside the library at commit 0e72e2e2c; taken from 12-an-optimisation-model.en.md(opens in a new tab)
Scope (1)
oN = new stzOptimModel()
oN.Vars([ :chairs = [ 0, :integer ], :tables = [ 0, :integer ] ])
oN.Maximize("30*chairs + 45*tables")
oN.SubjectTo([ "2*chairs + 5*tables <= 250", "chairs <= 60", "tables <= 60" ])
oN.Solve()
? @@( oN.Solution() )
? oN.Objective()
? oN.Branched()[ [ "chairs", 60 ], [ "tables", 26 ] ] 2970 1
run on 2026-10-02 04:25 inside the library at commit 0e72e2e2c; taken from 12-an-optimisation-model.en.md(opens in a new tab)
The extensions of this method
Each extension, and whether it exists for this method; an extension that exists combines with the others (FindSTCS).
Every example is a test file of the library, run inside the library for this page; only those whose output kept every promise their file wrote are shown.
See also
- The class stzOptimModel
- The area's reference: Numeric & optimization
- The other methods in these examples: stzOptimModel.Branched · stzOptimModel.Maximize · stzOptimModel.Objective · stzOptimModel.Solution · stzOptimModel.Solve · stzOptimModel.SolveWith · stzOptimModel.StatusWord · stzOptimModel.SubjectTo

