What Is Model JSON
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.
Looking for a machine-learning model.json? In TensorFlow.js, model.json is a different file: it stores a model’s architecture and a manifest of its binary weight files (.bin). This page is only about the CalcTypes optimisation-model format.
What is βmodel JSONβ in this calculator?
Model JSON is a plain-text file that stores your whole optimization model: objective, constraints, variable types and bounds, and solver options.
You can export it, save it and load it again later.
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
Schema used by the calculator’s Import and Export buttons
{
"problem": { "sense": "max" }, // "max" or "min"
"size": { "nVars": { "value": n }, "nCons": { "value": m } },
"vars": [ // one entry per variable
{ "name": "x1", "type": "integer", "lb": 0, "ub": null }
], // type: "integer", "binary" or "continuous"; ub null = no upper bound
"objective": { "c": [c1, c2, ..., cn], "constant": 0 },
"constraints": [ // one entry per constraint
{ "a": [a1, a2, ..., an], "sense": "<=", "b": rhs }
], // sense: "<=", ">=" or "="
"options": {
"method": "branch_and_bound", // or "branch_and_cut_small"
"showSteps": true,
"integralityTol": 1e-9,
"timeLimitMs": 5000,
"nodeLimit": 5000,
"branchingRule": "most_fractional", // or "largest_impact"
"searchStrategy": "best_bound" // or "depth_first"
}
}
This is the exact shape that Export model as JSON produces and Import model from JSON accepts (the // comments are explanations only; real JSON cannot contain comments). A share-link payload wraps the same object as {"calc": "ilp", "v": 1, "model": { β¦ }}, and the importer accepts that wrapper too.
Fields
Field-by-field meaning
| Field | Type | Meaning |
|---|---|---|
problem.sense | string | “max” or “min” (objective direction). |
size.nVars.value, size.nCons.value | integers | Number of decision variables and constraints. The calculator rejects a file without these two values (“Unsupported model JSON”). |
vars[i].name | string | Variable name shown in the tables (for example x1). |
vars[i].type | string | “integer”, “binary” or “continuous”. |
vars[i].lb, vars[i].ub | number or null | Lower and upper bound; null for ub means no upper bound. |
objective.c | array of numbers | Objective coefficients, so the objective is Ξ£ cα΅’xα΅’ (+ constant). |
objective.constant | number | Constant added to the objective (usually 0). |
constraints[j].a | array of numbers | Coefficients of x1β¦xn in constraint j. |
constraints[j].sense | string | “<=”, “>=” or “=”. |
constraints[j].b | number | Right-hand side of constraint j. |
options | object | Method, step display, integrality tolerance, time and node limits, branching rule and search strategy. |
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}
Model JSON (tested in the calculator on 13 November 2026):
{
"problem": {
"sense": "max"
},
"size": {
"nVars": {
"value": 2
},
"nCons": {
"value": 1
}
},
"vars": [
{
"name": "x1",
"type": "binary",
"lb": 0,
"ub": 1
},
{
"name": "x2",
"type": "binary",
"lb": 0,
"ub": 1
}
],
"objective": {
"c": [
5,
3
],
"constant": 0
},
"constraints": [
{
"a": [
2,
1
],
"sense": "<=",
"b": 3
}
],
"options": {
"method": "branch_and_bound",
"showSteps": true,
"integralityTol": 1e-9,
"timeLimitMs": 5000,
"nodeLimit": 5000,
"branchingRule": "most_fractional",
"searchStrategy": "best_bound"
}
}
Open Advanced sharing (Import/Export JSON) in the ILP/MILP calculator, paste this JSON into the box and click Import model from JSON. The tables fill with the model; click Solve. The result is optimal with z = 8 (x1 = 1, x2 = 1), because both projects fit within the budget of 3.
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: you can change coefficients, bounds, variable types or solver options, then import the file again.
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, invalid JSON is rejected, and mismatched lengths (for example size.nVars.value = 3 but only 2 numbers in objective.c) are silently filled with zeros, so check the tables after importing.
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 sizes (nVars, nCons and arrays)
The importer reads exactly size.nVars.value variables and size.nCons.value constraints. If an array is shorter, the missing coefficients are silently filled with 0; extra entries are ignored. Either way the model you solve is not the one you meant, so always check that:
varsandobjective.ceach havenVarsentries,constraintshasnConsentries and eachaarray hasnVarsnumbers,- every constraint has a
sense(“<=”, “>=” or “=”) and a numericb.
Mistakes
Mistake: editing numbers but forgetting to update bounds or types
If you change a variable from binary to continuous in vars[i].type 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.
Methodology: How This Guide Works
This guide explains the model JSON format used by CalcTypes optimisation tools using the standard textbook treatment found in operations-research courses (for example Hillier & Lieberman, Introduction to Operations Research, and Taha, Operations Research: An Introduction). Each step is written so you can repeat it by hand, and the worked examples use the same steps as the CalcTypes ILP solver, so you can reproduce them there.
Assumptions and Limitations
Assumptions
- The JSON follows the field names described in the guide (objective, constraints, variables, bounds).
- Numbers are plain decimal values, not formulas.
- Each constraint is linear.
Limitations
- Other solvers use different file formats (such as LP or MPS), so the JSON is not universally portable.
- Invalid JSON or unknown fields are rejected rather than guessed.
- Examples are small teaching problems; real problems usually need more constraints and data checks.
Disclaimer
Please read before relying on this page. This page on What Is Model JSON explains optimisation methods for study. Worked examples use simplified models; real problems usually need extra constraints and careful validation. Check methods against your course, and validate any model before using it for real decisions.
Your responsibility. Results are estimates for general information and education only, and nothing here is professional advice. You use this page at your own risk; to the fullest extent permitted by law, CalcTypes, its authors and reviewers accept no liability for loss, injury or damage arising from reliance on it. Spotted an error? Use βReport an issueβ or our contact page. Full terms: Disclaimer Β· Terms of use.