Constraints
Constraints are special components that allow you to add custom Python code to modify the optimisation problem. They store code blocks that are executed when building the optimisation model, enabling advanced users to implement custom operational rules and limits beyond the standard component attributes.
TIP
For detailed information on writing custom constraints, see the Custom Constraints section with working examples.
Properties
Constraint components are stored in the components table with component_type='CONSTRAINT' and have the following attributes:
| Attribute | Data Type | Unit | Default | Required | Storage Type | Description |
|---|---|---|---|---|---|---|
constraint_code | string | n/a | (empty) | Yes | static | Python code block defining constraint logic |
description | string | n/a | (empty) | No | static | Human-readable description of the constraint |
is_active | boolean | n/a | True | No | static | Whether constraint is active and should be applied |
priority | int | n/a | 0 | No | static | Execution priority (lower numbers execute first) |
Access in Convexity
In the Convexity application, navigate to Tables → Constraints to view, add, edit, or activate/deactivate custom constraints.
Learn More
- Custom Constraints Guide - Complete guide with examples
- Constraint Examples - Working code examples
- PyConvexity - Programmatic access to constraints

