Getting Started with Jia
Jia is a unified modelling language for constraint programming (CP) and linear programming (LP). You describe a problem as variables, their domains, and the constraints that must hold — then the solver finds a solution.
Model structure
Every Jia model follows an X, D, C pattern:
model <name>
variables { ... } // X — declare decision variables and their types
domains { ... } // D — bound variable attributes, assign set membership
constraints { ... } // C — relationships that must hold in any valid solution
minimize <expr> // optional objective
Sections can appear in any order. Comments start with //.
Your first LP model
Linear programming operates on continuous Real variables. Declare the model
type with @model lp at the top of the file.
@model lp
model simple_lp
variables {
Real: x, y
}
domains {
x in 0..inf
y in 0..inf
}
constraints {
x + y >= 10
}
minimize x + y
The solver will find the values of x and y that minimise x + y while
satisfying x + y >= 10 and both variables being non-negative. The optimal
solution is x = 0, y = 10 (or any split summing to 10).
Your first CP model
Constraint programming operates on Interval variables — tasks with a start
time, end time, and duration. CP models do not require an @model tag.
model two_tasks
variables {
Interval: task_a, task_b
}
domains {
duration(task_a) = 3
duration(task_b) = 2
}
constraints {
end_of(task_a) <= start_of(task_b)
}
minimize end_of(task_b)
This model schedules two tasks where task_a must finish before task_b
starts, and minimises when task_b finishes. The optimal schedule starts
task_a at 0 (ends at 3) and task_b at 3 (ends at 5).
Running a model
Use the jia-cp CLI for CP models and jia-lp for LP models:
# CP
jia-cp path/to/model.jia
# LP
jia-lp path/to/model.jia
Both print the objective value and the variable assignments found by the solver.
Next steps
- Syntax Reference — complete language grammar
- Constraint Reference — every constraint in detail
- Examples — real-world scheduling and optimisation problems