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