Semantic model
Model and ModelPackage represent supported variables, constraints, objectives, names, and source metadata.
A Unified Semantic Architecture for Heterogeneous Constraint Solving.
Qayd is a constraint-solving system written in Rust. Its semantic model connects finite-domain, routing, packing, assignment, and scheduling models to exact search, selected LCG and SAT paths, and local-search engines through one orchestration layer. The same model is available from Rust, Python, and standard input formats.
use qayd::model::{Constraint, Model, ModelPackage, Relation};
use qayd::orchestrator::{IgnoreEvents, SolveRequest};
let mut model = Model::new();
let x = model.int_range(0, 9);
model.add_constraint(Constraint::Linear {
terms: vec![(1, x)],
relation: Relation::Ge,
rhs: 4,
});
let result = qayd::solve(
&ModelPackage::new(model),
&SolveRequest::default(),
&mut IgnoreEvents,
).unwrap();
println!("{}", result.status().as_str()); // SATISFIABLE
import qayd as cp
weights = [4, 3, 2, 1]
profits = [8, 5, 6, 4]
model = cp.Model()
take = model.int_vars(4, 0, 1, name="take")
weight = sum(w * x for w, x in zip(weights, take))
profit = sum(p * x for p, x in zip(profits, take))
model.add(weight <= 5)
model.maximize(profit)
solution = model.solve(seed=0)
selected = [i for i, x in enumerate(take) if solution.value(x)]
print(solution.status, solution.objective, selected) # OPTIMAL 12 [0, 3]
import qayd as cp
distance = [
[0, 2, 4, 3], [2, 0, 1, 2],
[4, 1, 0, 1], [3, 2, 1, 0],
]
model = cp.Model()
customers = model.customers([1, 2, 3])
routes = model.routes(
customers, vehicles=1, depot=0, travel=distance,
)
model.minimize(routes.total_distance())
solution = model.solve(engine="exact")
print(solution.status, solution.objective) # OPTIMAL 7
import qayd as cp
model = cp.Model()
tasks = model.tasks(range(3))
for task, duration in zip(tasks, [3, 2, 4]):
task.duration = duration
schedule = model.schedule(tasks, horizon=9)
model.add(schedule[0].end <= schedule[1].start)
model.minimize(schedule.makespan())
solution = model.solve(engine="exact")
print(solution.status, solution.objective) # OPTIMAL 5
$ ./target/debug/qayd \
--seed 0 --threads 1 \
bench/golden/fixtures/xcsp_minimize.xml
o 1
s OPTIMUM FOUND
Qayd separates semantic modeling, solve planning, engine execution, and shared resource control.
Model and ModelPackage represent supported variables, constraints, objectives, names, and source metadata.
SolveRequest records the mode, seed, workers, limits, search policy, and optional controls. The orchestrator derives an executable solve plan.
Available backends include finite-domain propagation and branch-and-bound, selected LCG search paths, and beta SAT support. Some model families expose experimental local-search portfolios.
A common budget and stop signal cover preparation, compilation, worker startup, search, and persistent session epochs.
Typed helpers cover routing, packing, assignment, and interval scheduling. List and set models remain experimental.
Interfaces include Rust, Python, and XCSP3. FlatZinc, DIMACS, and OPB frontends are beta. Dataset readers include CVRPLIB, JSPLIB, and PSPLIB.
These commands build the workspace, install the Python extension, and run a tracked example.
cargo build --workspace
uv run maturin develop --profile pyext
uv run examples/python/optimization/search_policy.py