Task assignment with all_different, element, implication (CP-SAT)

Input

{
  "constraints": [
    {
      "type": "all_different",
      "vars": [
        "worker_t0",
        "worker_t1",
        "worker_t2"
      ]
    },
    {
      "index_var": "worker_t0",
      "target_var": "cost_t0",
      "type": "element",
      "values": [
        4,
        1,
        8
      ]
    },
    {
      "index_var": "worker_t1",
      "target_var": "cost_t1",
      "type": "element",
      "values": [
        4,
        3,
        5
      ]
    },
    {
      "index_var": "worker_t2",
      "target_var": "cost_t2",
      "type": "element",
      "values": [
        3,
        2,
        7
      ]
    },
    {
      "if_eq": 1,
      "if_var": "worker_t0",
      "then": {
        "op": ">=",
        "rhs": 2,
        "terms": [
          {
            "coeff": 1,
            "var": "worker_t2"
          }
        ],
        "type": "linear"
      },
      "type": "implication"
    }
  ],
  "objective": {
    "sense": "minimize",
    "terms": [
      {
        "coeff": 1,
        "var": "cost_t0"
      },
      {
        "coeff": 1,
        "var": "cost_t1"
      },
      {
        "coeff": 1,
        "var": "cost_t2"
      }
    ]
  },
  "timeout_ms": 3000,
  "variables": [
    {
      "max": 2,
      "min": 0,
      "name": "worker_t0"
    },
    {
      "max": 2,
      "min": 0,
      "name": "worker_t1"
    },
    {
      "max": 2,
      "min": 0,
      "name": "worker_t2"
    },
    {
      "max": 100,
      "min": 0,
      "name": "cost_t0"
    },
    {
      "max": 100,
      "min": 0,
      "name": "cost_t1"
    },
    {
      "max": 100,
      "min": 0,
      "name": "cost_t2"
    }
  ]
}

Output

Build-time verified. stats.elapsed_ms normalized to 0.

{
  "best_bound": 11,
  "objective_value": 11,
  "solution": {
    "cost_t0": 4,
    "cost_t1": 5,
    "cost_t2": 2,
    "worker_t0": 0,
    "worker_t1": 2,
    "worker_t2": 1
  },
  "stats": {
    "elapsed_ms": 0,
    "timed_out": false
  },
  "unsat_core": null,
  "verdict": "optimal",
  "verified": true
}

Request

curl --fail-with-body --silent --show-error https://oracles.burgeonads.com/v1/solve/cpsat -H 'Content-Type: application/json' --data-raw '{"variables":[{"name":"worker_t0","min":0,"max":2},{"name":"worker_t1","min":0,"max":2},{"name":"worker_t2","min":0,"max":2},{"name":"cost_t0","min":0,"max":100},{"name":"cost_t1","min":0,"max":100},{"name":"cost_t2","min":0,"max":100}],"constraints":[{"type":"all_different","vars":["worker_t0","worker_t1","worker_t2"]},{"type":"element","index_var":"worker_t0","values":[4,1,8],"target_var":"cost_t0"},{"type":"element","index_var":"worker_t1","values":[4,3,5],"target_var":"cost_t1"},{"type":"element","index_var":"worker_t2","values":[3,2,7],"target_var":"cost_t2"},{"type":"implication","if_var":"worker_t0","if_eq":1,"then":{"type":"linear","terms":[{"var":"worker_t2","coeff":1}],"op":">=","rhs":2}}],"objective":{"sense":"minimize","terms":[{"var":"cost_t0","coeff":1},{"var":"cost_t1","coeff":1},{"var":"cost_t2","coeff":1}]},"timeout_ms":3000}'