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]);
}