Serialization of the XCSP3 (core) format
XCSP3 is an integrated format for representing combinatorial constrained problems, which can deal with mono/multi optimization, many types of variables, cost functions, reification, views, annotations, variable quantification, distributed, probabilistic and qualitative reasoning. It is also compact, and easy to read and to parse. The objective of XCSP3 is to ease the effort required to test and compare different algorithms by providing a common test-bed of combinatorial constrained instances.
This crate focuses on the (de-)serializeation of the XCSP3 format. It can be used to parse an XCSP3 XML file into the provided rust types, or writing the provided rust types to an XCSP3 XML file.
Getting Started
Install xcsp3-serde and quick-xml for your package:
Once these dependencies have been installed to your crate, you could deserialize a XCSP3 XML file as follows:
# use Instance;
# use ;
# let path = new;
// let path = Path::new("/lorem/ipsum/instance.xml");
let rdr = new;
let instance: Instance = from_reader.unwrap;
// ... process XCSP3 ...
If, however, you want to serialize a XCSP3 instance you could follow the following fragment:
# use Instance;
let instance = default;
// ... create XCSP3 instance ...
let xml_str = to_string.unwrap;
Note that quick_xml::se::to_writer, using a buffered file writer, would be
preferred when writing larger instances.
Limitations
Not all XCSP3 features are currently implemented, the functionality of XCSP3-core is generally implemented and supported. This allows users to work with the most common constraint types and representations. Future updates will focus on expanding the range of supported XCSP3 features.