Trying to add lazy constraints to traveling salesman problem

if (ui - uj + lokasyon * xij <= lokasyon - 1) {
any chance this logic came from a system that uses [1] as first index of arrays?

I'm gonna remind you again:
Learn to use code tags, they make reading and commenting on source code MUCH easier.

How to use code tags:

There are other tags available.

How to use tags:

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either
Hmmmm, someone got booted, here's what was "said":

oxanaxu wrote:
for a simple traveling salesman problem, i am trying to add the "miller-tucker-zemlin subtour elimination constraints" by using ILOLAZYCONSTRAINTCALLBACK.

ILOLAZYCONSTRAINTCALLBACK3(lazycallback, BoolVarArray2, x, IloNumVarArray, u, IloCplex, tspcplex) {
IloInt const lokasyon = u.getSize();
for (IloInt i = 0; i < lokasyon; ++i) {
for (IloInt j = 0; j < lokasyon; ++j) {
IloNum ui = getValue(u[i]);
IloNum xij = getValue(x[i][j]);
IloNum uj = getValue(u[j]);
if (ui - uj + lokasyon * xij <= lokasyon - 1) {
cout << " Adding lazy constraint. i = " << i << " j = " << j << endl;

add(u[i] - u[j] + lokasyon * x[i][j] <= lokasyon - 1).end();

i need to getValues of my "decision variables" which are u[i] and x[i][j] to check if the subtour elimination constraitns are violated but cplex fails to solve.

i dont't have anything missing with the model, environment, objective function or other constraints.

tspcplex.use(lazycallback(tspenv, x, u, tspcplex));

after tspcplex.solve we go into the (sorry for the lame jargon) ILOLAZY... but we don't have a solution yet.

dear experienced optimizers, what am i missing?
Topic archived. No new replies allowed.