{"id":28188,"library":"sleipnirgroup-jormungandr","title":"Jormungandr","description":"Reverse mode automatic differentiation library and domain-specific language for nonlinear programming (NLP) solvers. Designed for efficient gradient and Hessian computations, it provides a Python DSL to formulate and solve optimization problems. Current version 0.5.4, requires Python >=3.12. Development is active with pre-1.0 breaking changes expected.","status":"active","version":"0.5.4","language":"python","source_language":"en","source_url":"https://github.com/SleipnirGroup/jormungandr","tags":["automatic-differentiation","optimization","nlp","solver","reverse-mode"],"install":[{"cmd":"pip install sleipnirgroup-jormungandr","lang":"bash","label":"latest from PyPI"}],"dependencies":[{"reason":"Required for array operations and interfacing with Jormungandr's symbolic types.","package":"numpy","optional":false},{"reason":"Optional but often used together for algorithm prototyping.","package":"casadi","optional":true}],"imports":[{"note":"The library is installed as sleipnirgroup-jormungandr but the top-level import package is 'jormungandr'.","wrong":"from sleipnirgroup_jormungandr import Jormungandr","symbol":"Jormungandr","correct":"from jormungandr import Jormungandr"},{"note":"The autodiff module is nested under the main 'jormungandr' package.","symbol":"autodiff","correct":"from jormungandr import autodiff"},{"note":"NlpSolver lives in the 'nlp' submodule, not at the top level.","wrong":"from jormungandr import NlpSolver","symbol":"NlpSolver","correct":"from jormungandr.nlp import NlpSolver"}],"quickstart":{"code":"from jormungandr import Jormungandr\n\n# Define variables\nx = Jormungandr.variable('x')\ny = Jormungandr.variable('y')\n\n# Define expression\nf = x**2 + y**2\n\n# Compute gradient (reverse mode)\ngrad = Jormungandr.gradient(f, [x, y])\nprint('Gradient at (1,2):', grad.eval({'x': 1, 'y': 2}))\n\n# Solve NLP\nfrom jormungandr.nlp import NlpSolver\nsolver = NlpSolver()\nsolver.set_objective(f)\nsolver.set_initial_guess({'x': 0.0, 'y': 0.0})\nsolution = solver.solve()\nprint('Solution:', solution)","lang":"python","description":"Minimal example showing variable creation, expression evaluation with reverse mode autodiff, and NLP solving."},"warnings":[{"fix":"Pin for production: sleipnirgroup-jormungandr==0.5.4","message":"API is unstable before 1.0. Expect changes in module names, function signatures, and behavior between minor versions. Pin your dependency to a specific minor version.","severity":"breaking","affected_versions":"<1.0"},{"fix":"Always use 'import jormungandr' or 'from jormungandr import ...'","message":"The package name on PyPI is 'sleipnirgroup-jormungandr' but the import is 'jormungandr'. Do not use the hyphens in import statements.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `auto_diff` with `gradient` in your code.","message":"The old autodiff API (e.g., `Jormungandr.auto_diff`) is deprecated in favor of `Jormungandr.gradient`. The old name may be removed in 0.6.","severity":"deprecated","affected_versions":">=0.5, <0.6"},{"fix":"Explicitly specify shape when creating non-scalar variables.","message":"Default variable types are symbolic scalars. To create vectors/matrices, use `Jormungandr.variable('x', shape=(3,))` or similar. Forgetting the shape leads to shape mismatch errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run 'pip install sleipnirgroup-jormungandr' then import using 'import jormungandr'","cause":"You installed the wrong package name or didn't install. The package is 'sleipnirgroup-jormungandr' but after install the import is 'jormungandr'.","error":"ModuleNotFoundError: No module named 'jormungandr'"},{"fix":"Use 'from jormungandr.nlp import NlpSolver' instead.","cause":"You tried to import NlpSolver from the top-level jormungandr module, but it is in the 'nlp' submodule.","error":"AttributeError: module 'jormungandr' has no attribute 'NlpSolver'"},{"fix":"Use 'Jormungandr.gradient(f, [x])' instead of 'Jormungandr.gradient(f, x)'","cause":"You passed a single variable instead of a list to Jormungandr.gradient(). The second argument must be a list even for one variable.","error":"ValueError: Gradient requires a list of variables"},{"fix":"Use 'x = Jormungandr.variable('x')' then 'f = x + 2'","cause":"You tried to perform arithmetic directly on the Jormungandr class instead of a variable instance. The class is the factory; you must create a variable first.","error":"TypeError: unsupported operand type(s) for +: 'Jormungandr' and 'int'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}