Original Message:
Sent: Thu February 29, 2024 10:33 AM
From: ALEX FLEISCHER
Subject: Re: Finding K shortest path through dijkstra's algorithm for columng generation
Hi,
obj should be declared before as dvar int obj;
See a very basic OPL model at https://github.com/AlexFleischerParis/zooopl/blob/master/zoo.mod
int nbKids=300;float costBus40=500;float costBus30=400; dvar int+ nbBus40;dvar int+ nbBus30; minimize costBus40*nbBus40 +nbBus30*costBus30; subject to{ 40*nbBus40+nbBus30*30>=nbKids;}
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Tue February 27, 2024 09:02 PM
From: Sheeba Pathak
Subject: Re: Finding K shortest path through dijkstra's algorithm for columng generation
Just typed the code, it has 4 errors, what's wrong?:-

------------------------------
Sheeba Pathak
Original Message:
Sent: Tue February 27, 2024 09:02 PM
From: ALEX FLEISCHER
Subject: Re: Finding K shortest path through dijkstra's algorithm for columng generation
Hi,
in OPL to get the shortest path you could use:
.mod
{int} nodes={i.o | i in edges} union {i.d | i in edges}; int st=1; // start int en=8; // end
dvar int obj; // distance dvar boolean x[edges]; // do we use that edge ?
minimize obj;
subject to { obj==sum(e in edges) x[e]*e.weight;
forall(i in nodes) sum(e in edges:e.o==i) x[e] -sum(e in edges:e.d==i) x[e] == ((i==st)?1:((i==en)?(-1):0)); }
{edge} shortestPath={e | e in edges : x[e]==1};
execute { writeln(shortestPath); }
.dat
edges= { <1,2,9>, <1,3,9>, <1,4,8>, <1,10,18>, <2,3,3>, <2,6,6>, <3,4,9>, <3,5,2>, <3,6,2>, <4,5,8>, <4,7,7>, <4,9,9>, <4,10,10>, <5,6,2>, <5,7,9>, <6,7,9>, <7,8,4>, <7,9,5>, <8,9,1>, <8,10,4>, <9,10,3>, };
But you could also implement Dijsktra in the scripting part of OPL or even call an external program in any language that will compute the shortest path you need (IloOplExec, IloOplJavaCall)
regards
#CPLEXOptimizers
#DecisionOptimization