I have implemented an XCSP3 parser whose repo is xcsp3-rust.
fn main(){
let problem = Problem::new();
}
fn main(){
let problem = Default::default();
}
fn main(){
let problem = problem!();
}
fn main(){
let problem = problem!();
problem += var!("var1"; 1=> 10);
problem += var!("var2";1=> 10);
problem += var!("var3";1=> 10);
problem += all_different!(
&problem["var1"],
&problem["var2"],
&problem["var3"]);
}
fn main() {
let mut problem = problem!();
let v1 = var!(&mut problem; "v1"; domain![7, 43, 22, 33, 2234]);
let v2 = var!(&mut problem; "v2"; domain![7, 43, 22, 33, 2234, 43]);
let v3 = var!(&mut problem; "v3"; 7, 43, 22, 33, 2234, 43);
let v4 = var!(&mut problem; "v4"; 1=>100);
let v4 = var!(&mut problem; "v5"; domain![1=>1000]);
problem += var!("v4"; 7=> 43);
problem += var!("v5";7, 54, 65, 43);
problem += var!("v6"; 7=> 43);
problem += bool!("v5");
problem += bool!("v6");
problem += bool!("vbool_1");
problem += bool!("vbool_2");
problem += bool!();
// you can get the variables by following code:
println!("{}",problem["v1"]);
println!("{}",problem["v4"]);
println!("{}",problem["v5"]);
println!("{}",problem[0]);
}
fn main() {
let mut problem = problem!();
for i in 0..n {
problem += var!(&format!("row_{}"; &i), 0=>(n as i32));
}
problem += all_different!(
&problem[format!("row_{}", i).as_str()],
&problem[i],
);
}
fn n_queens(n: usize) -> Problem {
let mut problem = problem!();
for i in 0..n {
problem += var!(&format!("row_{}"; &i), 0=>(n as i32));
}
for i in 0..n {
for j in i + 1..n {
problem += all_different!(
&problem[format!("row_{}", i).as_str()],
&problem[j]
);
}
}
problem
}