CalcTypes
Page

What Is Model JSON

Last updated: β€’ Sources β€’ Methodology

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: 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.

Important: model JSON for this calculator is not a universal MIP standard such as MPS or LP format. It is a practical format tailored to the CalcTypes ILP/MILP calculator.

Fields

Field-by-field meaning

FieldTypeMeaning
problem.sensestring“max” or “min” (objective direction).
size.nVars.value, size.nCons.valueintegersNumber of decision variables and constraints. The calculator rejects a file without these two values (“Unsupported model JSON”).
vars[i].namestringVariable name shown in the tables (for example x1).
vars[i].typestring“integer”, “binary” or “continuous”.
vars[i].lb, vars[i].ubnumber or nullLower and upper bound; null for ub means no upper bound.
objective.carray of numbersObjective coefficients, so the objective is Ξ£ cα΅’xα΅’ (+ constant).
objective.constantnumberConstant added to the objective (usually 0).
constraints[j].aarray of numbersCoefficients of x1…xn in constraint j.
constraints[j].sensestring“<=”, “>=” or “=”.
constraints[j].bnumberRight-hand side of constraint j.
optionsobjectMethod, 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

  1. Build your ILP/MILP model in the tables of the ILP/MILP calculator.
  2. Open the β€œAdvanced sharing (Import/Export JSON)” panel.
  3. Click β€œExport model as JSON.”
  4. Copy the JSON text and paste it into your notes, Git repo, or a shared document.

Workflow

Importing a model from JSON

  1. Paste a valid model JSON object into the β€œImport model from JSON” textarea.
  2. Click β€œImport model from JSON.” The tables should update to reflect the new model.
  3. 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:

  • vars and objective.c each have nVars entries,
  • constraints has nCons entries and each a array has nVars numbers,
  • every constraint has a sense (“<=”, “>=” or “=”) and a numeric b.

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

  1. Build a small ILP/MILP in the ILP/MILP calculator and export its model JSON.
  2. Check the JSON into version control (Git) alongside your data and reports.
  3. When you change a constraint or objective, update the JSON and write a short change note.
  4. 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.
Sources
  1. JSON.org β€” JavaScript Object Notation (JSON) Data Interchange Format
  2. Google OR-Tools β€” Modeling APIs and file formats
  3. AMPL β€” Modeling languages and model/instance separation