Crates.io | xcsp3-rust |
lib.rs | xcsp3-rust |
version | 0.1.0 |
source | src |
created_at | 2023-09-14 04:52:15.088629 |
updated_at | 2023-09-14 04:52:15.088629 |
description | xcsp3-rust is a library that help constraint programming solvers implemented by Rust to read XCSP3 files. |
homepage | |
repository | https://github.com/luhanzhen/xcsp3-rust |
max_upload_size | |
id | 972269 |
size | 380,834 |
[dependencies]
xcsp3-rust = "0.1.0"
fn main()
{
let xml_file = ".//instances//my-example.xml";
let model = XcspXmlModel::from_path(xml_file).unwrap();
let variable = model.build_variables();
println!("variables:");
for v in variable.iter() {
println!("\t{}", v);
match v {
XVariableType::XVariableNone(_) => {}
XVariableType::XVariableArray(_) => {}
XVariableType::XVariableInt(_) => {}
XVariableType::XVariableTree(_) => {}
}
}
println!("constraints:");
for c in model.build_constraints(&variable).iter_mut() {
println!("\t{}", c);
match c {
XConstraintType::XConstraintNone(_) => {}
XConstraintType::XExtension(_) => {}
XConstraintType::XAllDifferent(_) => {}
XConstraintType::XAllDifferentExcept(_) => {}
XConstraintType::XInstantiation(_) => {}
XConstraintType::XAllEqual(_) => {}
XConstraintType::XOrdered(_) => {}
XConstraintType::XRegular(_) => {}
XConstraintType::XMdd(_) => {}
XConstraintType::XIntention(_) => {}
XConstraintType::XGroup(_) => {}
XConstraintType::XSum(_) => {}
XConstraintType::XMaximum(_) => {}
XConstraintType::XMinimum(_) => {}
XConstraintType::XElement(_) => {}
XConstraintType::XSlide(_) => {}
XConstraintType::XCount(_) => {}
XConstraintType::XNValues(_) => {}
XConstraintType::XCardinality(_) => {}
XConstraintType::XChannel(_) => {}
XConstraintType::XCumulative(_) => {}
XConstraintType::XNoOverlap(_) => {}
XConstraintType::XStretch(_) => {}
}
}
println!("objectives:");
for o in model.build_objectives(&variable).iter() {
println!("\t{}", o);
match o {
XObjectivesType::XObjectiveNone(_) => {}
XObjectivesType::Minimize(e) => match e {
XObjective::XObjectiveElement(_) => {}
XObjective::XObjectiveExpression(_) => {}
},
XObjectivesType::Maximize(e) => match e {
XObjective::XObjectiveElement(_) => {}
XObjective::XObjectiveExpression(_) => {}
},
}
}
}
graph BT
A["XCSP(xml file)"] --serde--> B(XcspXmlModel)
B --parser--> C([XVariableSet])
B --parser--> D([XConstraintSet])
B --parser--> E([XObjectivesSet])
C --reader--> F[/example.rs/]
D --reader--> F
E --reader--> F
graph LR
C([XVariableSet]) -.->XVariableType(XVariableType)
XVariableType --> XVariableArray(XVariableArray)
XVariableType --> XVariableInt(XVariableInt)
XVariableType --> XVariableTree(XVariableTree)
XVariableTree -.domain.-> XDomainInteger(XDomainInteger)
XVariableInt -.domain.-> XDomainInteger
XVariableArray -.domain.-> XDomainInteger
XDomainInteger -.-> XIntegerType(XIntegerType)
XIntegerType -->IntegerValue(IntegerValue)
XIntegerType -->IntegerInterval(IntegerInterval)
XIntegerType -->XIntegerSymbolic(XIntegerSymbolic)
graph LR
D([XConstraintSet]) -.-> XConstraintType(XConstraintType)
XConstraintType --> XExtension(XExtension) -.scope.-> Scope(XVarVal)
XConstraintType --> XAllDifferent(XAllDifferent)-.scope.-> Scope
XConstraintType --> XAllDifferentExcept(XAllDifferentExcept)-.scope.-> Scope
XConstraintType --> XInstantiation(XInstantiation)-.scope.-> Scope
XConstraintType --> XAllEqual(XAllEqual)-.scope.-> Scope
XConstraintType --> XOrdered(XOrdered)-.scope.-> Scope
XConstraintType --> XRegular(XRegular)-.scope.-> Scope
XConstraintType -->XMdd(XMdd)-.scope.-> Scope
XConstraintType -->XIntention(XIntention)-.scope.-> Scope
XConstraintType -->XGroup(XGroup)-.scope.-> Scope
XConstraintType -->XSum(XSum)-.scope.-> Scope
XConstraintType -->XMaximum(XMaxMin)-.scope.-> Scope
XConstraintType -->XMinimum(XMaxMin)-.scope.-> Scope
XConstraintType -->XElement(XElement)-.scope.-> Scope
XConstraintType -->XSlide(XSlide)-.scope.-> Scope
XConstraintType -->XCount(XCount)-.scope.-> Scope
XConstraintType -->XNValues(XNValues)-.scope.-> Scope
XConstraintType -->XCardinality(XCardinality)-.scope.-> Scope
XConstraintType -->XChannel(XChannel)-.scope.-> Scope
XConstraintType -->XCumulative(XCumulative)-.scope.-> Scope
XConstraintType -->XNoOverlap(XNoOverlap)-.scope.-> Scope
XConstraintType -->XNoOverlapKDim(XNoOverlap)-.scope.-> Scope
XConstraintType --> XStretch(XStretch)-.scope.-> Scope
Scope -->IntVar(IntVar is a variable)
Scope -->IntVal(IntVal is a value)
graph LR
E([XObjectivesSet]) -.-> T(XObjectivesType)
%% XVariableArray(XVariableArray)
T --> Minimize(Minimize)
T --> Maximize(Maximize)
Minimize --> XObjective(XObjective)
Maximize --> XObjective(XObjective)
XObjective --> XObjectiveElement(XObjectiveElement)
XObjective --> XObjectiveExpression(XObjectiveExpression)
MIT License
luhan zhen
tip: Maybe my code is not the best, but I will keep improving it to better build our 'CP' community.