{"id":27882,"library":"jijmodeling","title":"JijModeling","description":"JijModeling is a Python library for mathematical modeling of optimization problems, with a focus on combinatorial optimization. It provides an intuitive API to define decision variables, constraints, and objective functions, and interfaces with solvers like JijZept. Current version 2.4.1, requires Python >=3.11, <4. Released regularly.","status":"active","version":"2.4.1","language":"python","source_language":"en","source_url":"https://github.com/Jij-Inc/jijmodeling","tags":["optimization","combinatorial","modeling","jijzept","mathematical-programming"],"install":[{"cmd":"pip install jijmodeling","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Wildcard import pollutes namespace; use 'import jijmodeling as jm'.","wrong":"from jijmodeling import *","symbol":"jm","correct":"import jijmodeling as jm"},{"note":"Direct import is fine, but typical usage via jm.Problem is recommended for clarity.","wrong":"from jijmodeling import Problem","symbol":"Problem","correct":"import jijmodeling as jm; problem = jm.Problem('name')"}],"quickstart":{"code":"import jijmodeling as jm\n\n# Define variables\nx = jm.BinaryVar('x', shape=(3,))\ny = jm.BinaryVar('y', shape=(3,))\n\n# Set problem\nproblem = jm.Problem('simple')\nproblem += x[0] + x[1] + x[2]\nproblem += jm.Constraint('c1', x[0] + y[0] == 1)\n\n# Solve (requires JijZept token)\ntoken = os.environ.get('JIJZEPT_TOKEN', '')\nif token:\n    import jijzept as jz\n    sampler = jz.JijSASampler(token)\n    result = sampler.sample(problem)\n    print(result)\nelse:\n    print('No JIJZEPT_TOKEN set. Problem defined:', problem)","lang":"python","description":"Define a simple binary optimization problem with variables, objective, and constraint."},"warnings":[{"fix":"Migrate from `jm.Model` to `jm.Problem`. Use `jm.BinaryVar` instead of `jm.Binary`. Check migration guide.","message":"In version 2.0+, the API changed significantly. The old `jijmodeling` standalone model definition (e.g., `jm.Model`) is replaced by `jm.Problem`. Code from v1.x must be rewritten.","severity":"breaking","affected_versions":">=2.0"},{"fix":"Always use `jm.Constraint` for comparisons. Do not use `if x[0] == 1:` in code logic.","message":"Variable indexing returns a placeholder, not the actual value. You cannot compare variables directly using Python comparison operators; use `==`, `<=`, `>=` only within constraints or objective expressions.","severity":"gotcha","affected_versions":"*"},{"fix":"Replace `jm.pw(...)` with `problem.add_piecewise(...)` or reformulate.","message":"The `jm.pw` (piecewise linear) function is deprecated in 2.4.0+. Use `jm.Problem.add_piecewise` or custom linearization.","severity":"deprecated","affected_versions":">=2.4.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `pip install jijmodeling` in the correct Python environment (Python >=3.11).","cause":"jijmodeling is not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'jijmodeling'"},{"fix":"Use `jm.Problem` instead of `jm.Model`.","cause":"In version 2.x, `Model` was renamed to `Problem`.","error":"AttributeError: module 'jijmodeling' has no attribute 'Model'"},{"fix":"Wrap comparisons in `jm.Constraint('name', expr)` or use `jm.Constraint(expr)`.","cause":"Using Python comparison operators like `>` outside of Constraint definition.","error":"JijModelingError: Cannot use operator '>' with Expression objects"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}