Skip to main content

Syntax Reference

Complete reference for the Jia modelling language.

Lexical elements

IDENT = [a-zA-Z_][a-zA-Z0-9_]*
NUMBER = [0-9]+
COMMENT = '//' .* NEWLINE

Whitespace (spaces, tabs, newlines) separates tokens and is otherwise ignored. Comments begin with // and extend to the end of the line.

Model header

Every model file begins with an optional model-type tag, then the model name:

(@model cp | @model lp)?
model IDENT

The @model tag is optional. When omitted the parser infers the type from the variable declarations: Real variables imply LP; Interval / Integer variables imply CP.

Variables block

Declares all decision variables. Each line specifies a type followed by one or more names:

variables_block = 'variables' '{' var_decl* '}'
var_decl = var_type ':' IDENT (',' IDENT)*

Variable types

TypeParadigmDescription
IntervalCPTask with a start time, end time, and duration
IntegerCPScalar integer decision variable
RealLPContinuous real-valued decision variable
Set[Interval]CPNamed collection of interval variables (e.g. all tasks on a machine)
Set[Integer]CPNamed collection of integer variables

Example

model variable_types

variables {
Interval: task_a, task_b
Integer: makespan
Set[Interval]: machine1, machine2
}

domains {
duration(task_a) = 3
duration(task_b) = 2
machine1 = {task_a}
machine2 = {task_b}
makespan in 0..100
}

constraints {
end_of(task_a) <= makespan
end_of(task_b) <= makespan
}

minimize makespan

Domains block

Bounds variable attributes and assigns set membership. The domain block accepts several statement forms.

domains_block = 'domains' '{' domain_stmt* '}'

Interval attribute statements

Constrain the duration, start, or end of one or more interval variables:

interval_attr_stmt = ('duration' | 'start' | 'end') '(' IDENT (',' IDENT)* ')' domain_spec
domain_spec = '=' NUMBER
| 'in' NUMBER '..' (NUMBER | 'inf')
| 'in' '{' NUMBER (',' NUMBER)* '}'

Fixed value — the attribute is exactly this number:

duration(task_a) = 5

Range — the attribute falls within an inclusive range:

start(task_a, task_b) in 0..20
end(task_c) in 0..50

Enumerated set — the attribute must be one of the listed values:

duration(task_a) in {1, 3, 5}

Multiple intervals can share a statement:

duration(task_a, task_b) = 3

Optional intervals

Mark intervals as optional — the solver may choose not to schedule them:

optional_stmt = 'optional' '(' IDENT (',' IDENT)* ')'
optional(alt_a, alt_b)

Used in flexible job-shop scheduling where exactly one alternative is selected.

Integer domain statements

Constrain an integer variable to a range or enumeration:

integer_domain_stmt = IDENT 'in' domain_value
makespan in 0..100
priority in {1, 2, 3}

Set membership

Assign which intervals belong to a named set:

set_domain_stmt = IDENT '=' '{' IDENT (',' IDENT)* '}'
machine1 = {task_a, task_c}
machine2 = {task_b, task_d}

Resource demand

Declare how much of a resource an interval consumes while active:

demand_stmt = 'demand' '(' IDENT ',' IDENT ')' '=' NUMBER
demand(task_a, res1) = 2
demand(task_b, res1) = 3

Used with the cumulative constraint to enforce capacity limits.

LP variable domains

For LP models, bound a Real variable using the same range syntax:

x in 0..inf
y in 0..8

Constraints block

States relationships that must hold in any valid solution.

constraints_block = 'constraints' '{' constraint_stmt* '}'

See the Constraint Reference for full details on each constraint type.

Objective

Optionally minimise or maximise an expression:

objective = ('minimize' | 'maximize') expr
minimize makespan
maximize end_of(last_task) - start_of(first_task)

If no objective is given, the solver finds any feasible solution.

Expressions

Expressions appear in comparison constraints, cumulative capacity arguments, and objectives.

expr = additive
additive = multiplicative (( '+' | '-' ) multiplicative)*
multiplicative = unary ( '*' unary )*
unary = '-' unary | atom
atom = NUMBER
| IDENT
| 'start_of' '(' IDENT ')'
| 'end_of' '(' IDENT ')'
| 'duration_of' '(' IDENT ')'
| 'present_of' '(' IDENT ')'
| '(' expr ')'

Standard arithmetic precedence applies: * binds tighter than + and -.

FormMeaning
42Integer literal
xVariable reference
start_of(t)Start time of interval t
end_of(t)End time of interval t
duration_of(t)Duration of interval t
present_of(t)1 if optional interval t is scheduled, 0 otherwise
a + b, a - b, a * bArithmetic
-aNegation
(a + b) * cGrouping