Original Message:
Sent: Sat December 13, 2025 12:54 AM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
I come to this conclusion because this is the behaviour I am seeing. Yes, it should equal one value throughout the whole model, but this doesn't appear to be the case.
It is very frustrating and disappointing when I'm now double-checking everything it spits out as a result, to constantly find this error.
Please PM me your email address and I'll send through the models where I am still encountering this odd behaviour.
I have also ran Intel Processor Diagnostic Tool and Memory Diagnostic, in case there is a hardware fault which could cause the calculation error. Both tests came back with passes.
------------------------------
Stevie Turkington
Original Message:
Sent: Thu December 11, 2025 05:36 AM
From: Olivier Lhomme
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
What dou mean by:
"It appears one variable equals a value in all equations it appears, bar one where it has a different value." ?
A variable is given only one value, there is no concept such as the value of variable X in a constraint C, so how can you say that the variable has different values in two constraints?
I second Alex, sending a code to show your problem is the best way to advance on this.
------------------------------
Olivier Lhomme
Original Message:
Sent: Wed December 10, 2025 01:17 PM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
For some reason, the software is saying a particular equation equals a certain value. Upon actually checking this, it does not. All other calculations are correct, apart from that one. There is no additional variable - declared (int) or decision (dvar int) - to factor in this difference. It appears one variable equals a value in all equations it appears, bar one where it has a different value.
The software is calling the erroneous calculation a solution to the problem.
------------------------------
Stevie Turkington
Original Message:
Sent: Wed December 10, 2025 10:27 AM
From: Olivier Lhomme
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Hello,
your question is not very clear for me, but just looking at the small partial model you sent, I can see 13 linear equalities (counting the constraints to be in a given discrete set as equalities), and 12 variables. So, to complete the model to a feasible one, you would need to give compatible values to the different entries. You problem is certainly related.
------------------------------
Olivier Lhomme
Original Message:
Sent: Tue December 09, 2025 11:14 PM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
I've managed to reduce the values decided for the decision variables to be 2 or 3 digits long. Even then, the issue I raised in my previous post persists. There is a serious calculation flaw.
------------------------------
Stevie Turkington
Original Message:
Sent: Tue December 09, 2025 01:37 AM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Unfortunately, I continue to face difficulties. It is not a matter of "large numbers", the calculations match when I check them apart from one.
It seems an optimal solution is the values already provided for PLUS whatever number is necessary to "make one line work". However, there is no variable to factor in this "number to make it work". It is not accounted for but is being calculated as if there is that additional variable. This shouldn't be occuring so why is it happening?
If there is a solution, it should satisfy the constraints. The software should not be adding adhoc numbers to "make it work" and purport to display feasible solutions, because a calculated value isn't what it says it is when you don't factor in whatever the software has decided to add (eg in one line a variable is valued x, but the same variable in another line is calculated on the basis x + "adhoc number").
------------------------------
Stevie Turkington
Original Message:
Sent: Mon December 08, 2025 01:34 PM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Hi Alex
Expanding on my earlier example, is this the most effective and efficient way to code the following optimization problem:
using CP;int variable1 = #; int variable6 = #;int variable8 = #;dvar int variable2;dvar int variable3;dvar int variable4;dvar int variable5;dvar int d;dvar int b;dvar int c;dvar int p;dexpr int variable7 = variable4 + variable5;subject to {variable2 in {set of #'s};variable3 in {set of #'s};variable7 in {set of #'s};d in {set of #'s};b == variable8 + variable7;c == variable1 + variable2;d == variable3 - variable4; p == c - d;p - variable5 == variable6;}
I had accidentally written both variable2 + variable5 = variable7 and variable2 + variable3 = variable7 in my first example.
The only equation which should apply in that is variable2 + variable3 = variable7. I have, nonetheless, expanded on the example in this post.
------------------------------
Stevie Turkington
Original Message:
Sent: Mon December 08, 2025 02:55 AM
From: ALEX FLEISCHER
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Hi,
again if you want other users to have a look, you could share your rentire model and data so that other users could try
regards
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Fri December 05, 2025 01:58 AM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Thank you.
Unfortunately, I am still encountering issues with the validity of calculations.
I split a long equation into smaller parts, which for some reason gives me more solutions than when it was one big equation (constraints in both instances). This is despite nothing in the objective function changing.
In fact, I get completely different values for the DVs - and they don't satisfy the (as an eg) int variable6 = 3 parameter.
The one long equation does, but at the expense of other calculations not actually being what they say they are.
Is this some kind of bug within the software?
I double check everything now, given all the problems I've experienced with a solution purporting to be feasible, when in fact it isn't.
------------------------------
Stevie Turkington
Original Message:
Sent: Thu December 04, 2025 04:48 AM
From: ALEX FLEISCHER
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
Hi,
no need of ILOG script, you can do that with OPL only:
using CP; int variable1=2; int variable6=3; dvar int variable2; dvar int variable3 ; dvar int variable4; dvar int variable5; dexpr int variable7=variable2+variable3; dvar int c; dvar int d; dvar int p; subject to { variable2 in {1,2,3,8,10}; variable3 in {1,2,3,8,10,12};; c == variable1 + variable2; d == variable3 + variable4; p == c - d; p - variable5 == variable6; variable2 + variable5 == variable7; }
works fine
See some scripting examples I shared to see what OPL scripting is good for
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Wed December 03, 2025 09:23 PM
From: Stevie Turkington
Subject: Tips & Tricks for Effective and Efficient ILOG Script Code
I have some questions on the best and most efficient way to produce an optimization problem in the ILOG Script programming language, invoking CP Optimizer:
The structure of the example model is:
- c = variable1 + variable2
- d = variable3 + variable4
- p = c - d
- p - variable5 = variable6
- variable2 + variable5 = variable7
where:
- variable1 is a model parameter (user-defined value).
- variable2, variable3, variable4, and variable5 are decision variables.
- variable2 and variable3 take on values defined in lists of allowable values.
- variable6 is required to take on one user-defined value.
- variable7 is the sum of variable2 and variable3, which also needs to equal a value defined in a list of allowable values.
What is the best way to write these using ILOG Script (eg use of constraints, expr int, dvar int, int)?
Also, should variable6 be expressed as a constraint or defined as a model parameter?
------------------------------
Stevie Turkington
------------------------------