What Is Model JSON? Save, Share, and Restore ILP/MILP Models in the Calculator
βModel JSONβ is the structured text format the CalcTypes ILP/MILP calculator uses to store everything about your optimization model: objective, variables, constraints, bounds, and solver options.
You can export this JSON, share it with a teammate, or paste it back into the Integer Linear Programming calculator to restore the exact same model and re-solve itβwith no manual retyping.
On this page
- Quick takeaway
- What is βmodel JSONβ in this calculator?
- Model JSON structure (fields and meaning)
- A complete example: model JSON for a tiny ILP
- Questions people ask about model JSON
- How to import and export model JSON safely
- Sharing models with colleagues (URLs vs JSON)
- Common mistakes & troubleshooting
- What to do next
Quick takeaway: Model JSON is a human-readable JSON document that fully describes your ILP/MILP model for the CalcTypes Integer Linear Programming calculator. It includes objective coefficients, constraint matrices, right-hand sides, variable types and bounds, and solver options. Exporting and importing this JSON lets you back up models, share them, and regenerate exact runs.
What is βmodel JSONβ in this calculator?
Definition
A portable description of your optimization model
JSON (JavaScript Object Notation) is a widely used structured text format. In this context, model JSON is a JSON object that captures:
- Objective sense (maximize or minimize),
- Objective coefficients,
- Constraint matrix and senses (β€, =, β₯),
- Right-hand-side values,
- Variable types (continuous, integer, binary) and bounds,
- Key solver options (integrality tolerance, time/node limits, method choice).
When you click βExport model as JSONβ in the ILP/MILP calculator, you get this structure as a text block you can save or share.
Model JSON structure (fields and meaning)
Structure
High-level schema (informal)
{
"sense": "max" or "min",
"n": <number of variables>,
"m": <number of constraints>,
"c": [c1, c2, ..., cn], // objective coefficients
"A": [[...], [...], ...], // m Γ n constraint matrix
"b": [b1, b2, ..., bm], // right-hand sides
"senseRows": ["<=", "=", ">=", ...],
"varTypes": ["C","I","B", ...], // C=continuous, I=integer, B=binary
"lb": [l1, l2, ..., ln], // lower bounds
"ub": [u1, u2, ..., un], // upper bounds
"options": {
"method": "branch_and_bound" or "branch_and_cut_small",
"timeLimitMs": 5000,
"nodeLimit": 5000,
"integralityTol": 1e-9,
"showSteps": true,
"branchingRule": "most_fractional",
"searchStrategy": "best_bound"
}
}
The exact field names may evolve as the calculator grows, but the intent remains: one JSON object contains everything needed to re-create your ILP/MILP run.
Fields
Field-by-field meaning
| Field | Type | Meaning |
|---|---|---|
sense |
string | "max" or "min" (objective direction). |
n, m |
integers | Number of decision variables and constraints. |
c |
array of numbers | Objective coefficients c_i so that the objective is Ξ£ c_i x_i. |
A |
2D array | Constraint matrix; A[j][i] is coefficient of x_i in constraint j. |
b |
array of numbers | Right-hand sides of constraints. |
senseRows |
array of strings | Constraint sense per row: "<=", ">=", or "=". |
varTypes |
array of strings | "C"=continuous, "I"=integer, "B"=binary. |
lb, ub |
arrays of numbers | Lower and upper bounds for each variable. |
options |
object | Solver-related settings (method, limits, integrality tolerance, logging). |
A complete example: model JSON for a tiny ILP
Example
Project selection example (0β1 ILP)
Model:
maximize 5 x1 + 3 x2
subject to 2 x1 + 1 x2 β€ 3
x1, x2 β {0,1}
One possible model JSON representation:
{
"sense": "max",
"n": 2,
"m": 1,
"c": [5, 3],
"A": [[2, 1]],
"b": [3],
"senseRows": ["<="],
"varTypes": ["B", "B"],
"lb": [0, 0],
"ub": [1, 1],
"options": {
"method": "branch_and_bound",
"timeLimitMs": 5000,
"nodeLimit": 5000,
"integralityTol": 1e-9,
"showSteps": true,
"branchingRule": "most_fractional",
"searchStrategy": "best_bound"
}
}
If you paste this JSON into the βImport model from JSONβ box in the ILP/MILP calculator and click βImport,β the tables will be filled with this model. Click βSolveβ to re-run the optimization exactly.
Questions people ask about model JSON
People ask
Is model JSON specific to CalcTypes, or is it a standard?
Model JSON as described here is **specific to the CalcTypes ILP/MILP calculator**. Itβs designed to be easy to read and manipulate, but it is not an official MPS/LP/MIP standard. Many solvers have their own formats (e.g., MPS, LP files, ProtoBufs).
People ask
Can I edit model JSON by hand?
Yes, for small models and careful users. You can:
- Change coefficients, bounds, or types,
- Adjust solver options (time limits, integrality tolerance),
- Add/remove constraints and variables (keeping dimensions consistent).
However, typos or mismatched lengths (e.g., n not matching the length of c) will cause errors or undefined behavior.
People ask
Is model JSON stable over time?
The core fields (objective, constraints, types, bounds) are expected to remain stable.
Additional fields may be added to options as new solver features are exposed.
The calculator will aim to be backward-compatible with reasonable older JSON files; when breaking changes are needed, they will be documented.
How to import and export model JSON safely
Workflow
Exporting your current model
- Build your ILP/MILP model in the tables of the ILP/MILP calculator.
- Open the βAdvanced sharing (Import/Export JSON)β panel.
- Click βExport model as JSON.β
- Copy the JSON text and paste it into your notes, Git repo, or a shared document.
Workflow
Importing a model from JSON
- Paste a valid model JSON object into the βImport model from JSONβ textarea.
- Click βImport model from JSON.β The tables should update to reflect the new model.
- Click βSolveβ to run the model with the current solver options.
Tip: if import fails, check your JSON with a validator (e.g., jsonlint.com) to ensure itβs syntactically correct.
Sharing models with colleagues (URLs vs JSON)
Sharing
Model JSON vs share links
| Method | What it contains | When to use |
|---|---|---|
| Model JSON | Full model structure & solver options; editable as text. | Versioning, code review, documentation, programmatic editing. |
| Share link | A URL with a hash (#wt=...&autocalc=1) that restores the model in the calculator. |
Quick sharing in chats/emails; no editing necessary. |
In the ILP/MILP calculator, both options are available. For long-term storage, model JSON is usually better; for quick reproduction, share links are convenient.
Common mistakes & troubleshooting
Mistakes
Mistake: mismatched dimensions (n, m, and arrays)
If n says β3 variablesβ but your vectors/rows have 2 or 4 elements, import will fail or behave incorrectly.
Always ensure that:
c.length == n,A.length == mand each row has lengthn,b.length == m,varTypes.length == n,lb.length == n,ub.length == n.
Mistakes
Mistake: editing numbers but forgetting to update bounds or types
If you change a variable from binary to continuous in varTypes but leave its bounds at [0,1], the model logic may change more than expected.
Similarly, converting a continuous variable to integer without updating bounds can unexpectedly enlarge the search space.
What to do next
Next steps
Make model JSON part of your modeling workflow
- Build a small ILP/MILP in the ILP/MILP calculator and export its model JSON.
- Check the JSON into version control (Git) alongside your data and reports.
- When you change a constraint or objective, update the JSON and write a short change note.
- Use share links for quick collaboration, and model JSON for long-term reproducibility.
Disclaimer
This description of the CalcTypes model JSON format is provided for educational and informational purposes only. The JSON schema may evolve over time as new features are added to the calculators. Always consult the live calculator and associated methodology notes when relying on JSON-based workflows, and do not treat this format as a universal MIP standard.