3
$\begingroup$

I try to implement cp model with OR-tools CP-SAT solver. Please, is it possible to name constraints for being able to manage conflict later like for variables: t_var[i] = model.NewBoolVar(f"affect_{i}")

$\endgroup$

2 Answers 2

6
$\begingroup$

Setter:

ct = model.Add(x == 2).WithName("my_ct")

Getter:

ct_name = ct.Name()
$\endgroup$
1
  • $\begingroup$ Thanks, it is good, 'model.Add(z_var[edge_iter] for adge_iter in ens_edges if edge_iter[0] == v).WithName(f"ct_{v}")' $\endgroup$
    – Issouf
    Commented Sep 25, 2023 at 19:02
-1
$\begingroup$
C1 = model.addConstrs(<<expr>>, name = 'C1'+str(i))
$\endgroup$
2
  • $\begingroup$ the question is about the CP-SAT api, not the Gurobi one. $\endgroup$ Commented Sep 25, 2023 at 19:00
  • $\begingroup$ I think that this formulation is for GUROBI $\endgroup$
    – Issouf
    Commented Sep 25, 2023 at 19:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.