0

I am new to Choco. I found an example online saying showing how to set the object as below

// Model objective function 3X + 4Y
IntVar OBJ = model.intVar("objective", 0, 999);
model.scalar(new IntVar[]{X,Y}, new int[]{3,4}, OBJ)).post();
// Specify objective
model.setObjective(Model.MAXIMIZE, OBJ);

What if my coeffs is double value? More specifically, if my objective function is 3.5X+4.2Y, how can I set the Objective? Please help. Thanks.

Laodao
  • 1,547
  • 3
  • 17
  • 39
  • not the focus of your question, but Java naming conventions would say `IntVar obj` (instead of `IntVar OBJ`). – Kaan Oct 02 '19 at 23:04
  • Constraint programming is int-focused. While choco might support floats (cant check now), i would still recommend to simply scale: 3.5x + 4.2 y becomes 35 x + 42 y. This is not uncommon. – sascha Oct 07 '19 at 17:45
  • Thanks @sascha. Please put your comment as an answer so I can accept it. – Laodao Oct 07 '19 at 18:51

0 Answers0