Crate xcsp3_serde
source ·Expand description
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:
cargo add xcsp3-serde quick-xml
Once these dependencies have been installed to your crate, you could deserialize a XCSP3 XML file as follows:
// let path = Path::new("/lorem/ipsum/instance.xml");
let rdr = BufReader::new(File::open(path).unwrap());
let instance: Instance = quick_xml::de::from_reader(rdr).unwrap();
// ... process XCSP3 ...
If, however, you want to serialize a XCSP3 instance you could follow the following fragment:
let instance = Instance::<String>::default();
// ... create XCSP3 instance ...
let xml_str = quick_xml::se::to_string(&instance).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.
Modules§
- Constraints
- Expressions for constraints and objectives
Structs§
- Definition of a k-dimensional arrays of variables
- XCSP3 problem instance
- An assignment from a list of variables to a list of values
- Type used to capture optional metadata that can be attached to most XCSP3 elements
- Expression used to represent an objective function
- Collection of objective functions
- A sorted collection of inclusive ranges that can be used to represent non-continuous sets of values.
- Definition of a variable
Enums§
- The way in which combinations of objectives are to be evaluated
- The framework of an XCSP3 instance
- An expression used to access a single element or a larger part of an array
- The type of instantiation
- Evaluation method for the list of expressions in an objective function
- Objective function
- Reference to a variable, array element, or array slice
Type Aliases§
- Type used to represent integer values