0

I have an IntVar array that should contain penalties. They are computed by multiplying the difference of a and b with attr[2]. But if the attr[3] is 1 I want to square the difference before multiplying with attr[2]. I can't find a View that would do that but with what I'm trying so far it takes way longer to find a solution and if I do, I get an assert error. Is there a way to achieve what I'm trying to do?

if(attr[3] == 1){
  IntVar difSq = VF.bounded("squared difference", 0, 500, solver);
  solver.post(ICF.square(difSq, VF.abs(VF.offset(a, -b))));
  penalty[i] = VF.scale(difSq, attr[2]);
}else{
  penalty[i] = VF.scale(VF.abs(VF.offset(a, -b)), attr[2]);
}
Dora
  • 47
  • 1
  • 8
  • This is some of the errors I get: FAILURE >> squared difference = [1,2] ################################################## FAILURE >> Square ([squared difference = [1,2] = |(scheduled hours+-16)| = 1^2]) – Dora Mar 30 '16 at 15:01
  • I am no expert but if you add a bit more code to help me figure out what you're doing and what you're trying to achieve I can take a look and help you. – dabadaba Mar 31 '16 at 18:55

0 Answers0