Skip to main content

MILP Visualizer

Turn a MILP/LP model into a 2D map of its structure using graph embedding. Variables placed closer together are more "similar" in some sense. In a CVRP model, for example, each vehicle forms its own cluster, and each cluster breaks down further into sub-clusters per customer node. Since these patterns emerge from problem structure and not variable names, similar models produce similar looking maps. This introduces a way to structurally compare different models, without the need of initial knowledge.

Install

pip install milp_visualizer

Quick start

import milp_visualizer

milp_visualizer.visualize("model.mps")                 # or "model.lp"

Creates variable_graph.html, which contains the final result.

Works directly on live solver models too, no file needed:

import gurobipy as gp

model = gp.Model()
# ... build model ...
milp_visualizer.visualize(model)

Similarly, HiGHS and ortools models can be visualized by supplying the model as first parameter.

Usage

milp_visualizer.visualize(
    source,                     # path (str/Path) or a Gurobi/HiGHS/OR-Tools model
    output=None,                # output path e.g. "graph.html" or "graph.png"; default: variable_graph.html / constraint_graph.html
    mode="variables",           # "variables" or "constraints"
    exclude=None,               # drop nodes before graph construction list of prefixes and globs
    groups=None,                # merge related nodes into one before embedding
    max_neighbors=None,         # cap edges drawn per node
    label_nodes=None,           # annotate node names (default: auto for <=50 nodes)
    node_categories=None,       # {node_name: hex_color} manual color override
)

exclude / groups syntax

Both take a string (or list of strings). Plain strings are a prefix match; strings containing * or ? are a glob:

  • * captures an integer - used by groups to partition nodes by that value
  • ? matches any integer without capturing it
milp_visualizer.visualize("model.mps", exclude="slack_")   # drop all slack_* variables
milp_visualizer.visualize("model.mps", groups=["x[?,*]"])  # group x[i,j] by j

Output files

visualize() writes one file, based on output's extension:

  • .html (default, recommended) - interactive Plotly scatter
  • .png - static matplotlib scatter

License

GPL

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

milp_visualizer-0.1.0.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

milp_visualizer-0.1.0-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file milp_visualizer-0.1.0.tar.gz.

File metadata

  • Download URL: milp_visualizer-0.1.0.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for milp_visualizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e33ffe62d64ebcf0cc03d247f3e73d7eb8aaeda19d54d5793f0f01a04aa81e9
MD5 fcddcdc8ab54bad6179faa781119034a
BLAKE2b-256 e4824c512c77d2ba878edb451e5660209a1894080fef8fbbefb0b90725b97f35

See more details on using hashes here.

Provenance

The following attestation bundles were made for milp_visualizer-0.1.0.tar.gz:

Publisher: publish.yml on Agoraaa/milp-visualizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file milp_visualizer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: milp_visualizer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for milp_visualizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8b2fc1021320978f19111a6d5a83aeec426f8270db551ede342779768530b5
MD5 4e71032209ba1258b796a6fe23d33729
BLAKE2b-256 d82cee05b01f2c2bf51c61a8e1052273058e4f258ba232d3c9afdbeb1c809f35

See more details on using hashes here.

Provenance

The following attestation bundles were made for milp_visualizer-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Agoraaa/milp-visualizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page