1. Initial Setup

1.1. Package Structure

ConstraintHg has four major components:
  • Structures for forming the major elements of constraint hypergraph (nodes, edges, as well as the full hypergraph itself).

  • Structures for representing simulation paths, given as a search tree.

  • Pathfinding algorithms for constructing a simulation.

  • Several predefined methods to help developers when constructing relationships.

1.2. Installation

Note

ConstraintHg is a Python package. The recommended way to use Python packages is to setup a virtual environment by calling python -m venv .venv from your terminal.

The best way to install the package is to use pip. Start by opening up a terminal and activating your virtual environment. Then, enter the following command:

pip install constrainthg

This will install the ConstraintHg source code from the Python Package Index (PyPI) to your working directory. It will also import the numpy package.

1.3. Calling the Package

After installing ConstraintHg, you can call it from a Python script. Open a new file in your directory and give it a name. We’ll call ours demo_pendulum.py.

Inside the blank file, import the ConstraintHg package. You typically don’t need to import the whole thing, just the classes for the Hypergraph and Node, as well as the relations class. To do this, add the following lines to your file:

from constrainthg.hypergraph import Hypergraph, Node
import constrainthg.relations as R

You’re now ready to move onto creating your model. Click here to go to the next step, or use the navigation links below.