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}")


2 Answers 2



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


ct_name = ct.Name()
  • $\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
    Sep 25, 2023 at 19:02
C1 = model.addConstrs(<<expr>>, name = 'C1'+str(i))
  • $\begingroup$ the question is about the CP-SAT api, not the Gurobi one. $\endgroup$ Sep 25, 2023 at 19:00
  • $\begingroup$ I think that this formulation is for GUROBI $\endgroup$
    – Issouf
    Sep 25, 2023 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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