PyCSP3
Models & Data GitHub XCSP3 About

XCSP3

XCSP3 is an XML-based format designed to represent instances of combinatorial constrained problems from the angle of Constraint Programming (CP). XCSP3 is an intermediate integrated format that can represent each instance separately while preserving its structure. For only dealing with the most popular constraints and frameworks, use XCSP3-core.

⇒ See the dedicated website of XCSP3


Here, we simply present two XCSP3 instances for two well-known problems:

Knapsack problem

<instance format="XCSP3" type="COP">
  <variables>
    <array id="x" size="[5]"> 0 1 </array>
  </variables>
  <constraints>
    <sum>
      <list> x[] </list>
      <coeffs> 11 24 5 23 16 </coeffs>
      <condition> (le,100) </condition>
    </sum>
  </constraints>
  <objectives>
    <maximize type="sum">
      <list> x[] </list>
      <coeffs> 46 46 38 88 3 </coeffs>
    </maximize>
  </objectives>
 </instance>
 
 
 

All Interval problem

<instance format="XCSP3" type="CSP">
  <variables>
    <array id="x" size="[5]" note="x[i] is the ith value of the series">
      0..4
    </array>
    <array id="y" size="[4]" note="y[i] is the distance between x[i] and x[i+1]">
      1..4
    </array>
  </variables>
  <constraints>
    <allDifferent> x[] </allDifferent>
    <allDifferent> y[] </allDifferent>
    <group class="channeling">
      <intension> eq(%0,dist(%1,%2)) </intension>
      <args> y[0] x[0] x[1] </args>
      <args> y[1] x[1] x[2] </args>
      <args> y[2] x[2] x[3] </args>
      <args> y[3] x[3] x[4] </args>
    </group>
  </constraints>
</instance>