VRP algorithm

1,592 views
Skip to first unread message

alessio88

unread,
May 15, 2012, 3:20:16 PM5/15/12
to am...@googlegroups.com

Hi, I'm using a VRP algorithm that gives me the perfect solution but it takes
too much time to solve problems with more than 12 nodes. I post them the
.mod and the .dat files

param n >= 0;
param K >= 0;
param C >= 0;
set N := 0..n;
set A := {i in N, j in N: i <> j};
param c{A} >= 0;
param d{1..n};
var x{A} binary;
var u{1..n} >= 0 ;
minimize costo: sum{i in N, j in N: i<>j} c[i,j]*x[i,j];
s.t. arcoentrante{j in 1..n}: sum{i in N: i <> j} x[i,j] = 1;
s.t. arcouscente{i in 1..n}:
sum{j in N: j <> i} x[i,j] = 1;
s.t. veicoli: sum{j in 1..n} x[0,j] <= K;
s.t. sottocicli{i in 1..n, j in 1..n: i <> j}: u[j] - u[i] + C*x[i,j] <= C -
d[i];
s.t. bound{i in 1..n}: d[i] <= u[i] <= C;


param n := 7;
param K := 10;
param C := 150;
param d := 1 50, 2 50, 3 50, 4 150, 5 50, 6 50, 7 50;
param c : 0 1 2 3 4 5 6 7:=
0 . 4.5 6.5 7.5 10 13 10 10
1 8.5 . 1.9 3 2.7 14 12 12
2 13 5 . 1.1 3.5 16 13 13
3 12 4.5 4.5 . 2.4 14 12 12
4 13 6.5 5 6 . 16 13 13
5 8.5 16 15 16 19 . 2.6 9
6 6 14 13 14 16 2.6 . 1
7 5.5 13 12 13 15 3.5 8 .;

Can you give me a heuristic model in AMPL mod file? Thank you very much
--
View this message in context: http://old.nabble.com/VRP-algorithm-tp33850933p33850933.html
Sent from the AMPL mailing list archive at Nabble.com.

Iván Riera

unread,
May 20, 2012, 3:56:14 PM5/20/12
to AMPL Modeling Language
I have mine almost perfect...but still not working:

###Sets aNd parameters###
param N :=17;
param k :=3;
set dem_Nodes := {2..N};
set Nodes ordered := {1..N};
set veh := {1..k};
set Arcs := {i in Nodes, j in Nodes: i<>j};
param Q{veh}>0;
param q{Nodes}>=0;
param C{Arcs};


###Variables###
var x{Arcs, veh}, binary;
var y{Arcs}, binary;
#var z{Nodes}, integer;


###The objective fuNctioN###
minimize Total_cost:
sum {t in veh} sum {(i,j) in Arcs} C[i,j] * x[i,j,t];

###CoNstraints###
#Starting from depot (Node 1), a vehicle must visit a customer i.
subject to Start{j in dem_Nodes}:
sum{i in Nodes: i<>j} y[i,j]=1;


#After visiting a customer i,the vehicle must leave for aNother
customer j.
subject to CoNtinue{i in dem_Nodes}:
sum{(i,j) in Arcs: i<>j} y[i,j]=1;


#The Nº of vehicles going from Node 1 to all Nodes j must be equal to
k.
subject to Going:
sum{j in dem_Nodes, i in Nodes: i<>j} y[1,j]=k;


#The Nº of vehicles returNing to Node 1 from all Nodes i must be equal
to # k.

subject to Backing:
sum{i in dem_Nodes, j in Nodes: i<>j} y[i,1]=k;


#Each vehicle must carry less thaN or equal to its capacity.
subject to Capacity:
sum {t in veh} sum {i in dem_Nodes, j in Nodes: i<>j}
x[i,j,t]*q[j]<=Q[k];


#There must be a link betweeN xkij aNd yij variables. Each Node,
except


#the depot, caN oNly be served oNce by oNly oNe vehicle.
subject to Served:

sum{i in Nodes, j in Nodes: i<>j} x[i,j,1] + sum{i in
Nodes, j in
Nodes: i<>j} x[i,j,2] + sum{i in Nodes, j in Nodes: i<>j} x[i,j,3]
=sum{i in Nodes, j in
Nodes: i<>j} y[i,j];


#The solutioN must Not coNtain aNy cycle using the Nodes 2,3,..,N.
Not
#coNtain aNy subtours of these Nodes.

subject to Servedonly:
sum {t in veh} sum{i in Nodes, j in Nodes: i<>j} x[i,j,t]
= sum{i in Nodes, j in Nodes: i<>j} y[i,j];

If you see the fail and you can run it, please tell me!!

alessio88

unread,
May 21, 2012, 2:15:36 PM5/21/12
to am...@googlegroups.com

Your model seems to be correct but you haven't written the data, solving it
AMPL gives:

Error executing "solve" command:
error processing objective Total_cost:
no value for C[1,2]

I use the student edition so if the variables or the constraits are more
than 300 the program doesn't work,
with N=17 I don't know if it could run.
> --
> You received this message because you are subscribed to the Google Groups
> "AMPL Modeling Language" group.
> To post to this group, send email to am...@googlegroups.com.
> To unsubscribe from this group, send email to
> ampl+uns...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ampl?hl=en.
>
>
>

--
View this message in context: http://old.nabble.com/VRP-algorithm-tp33850933p33884444.html

adel ali

unread,
Mar 5, 2013, 9:47:59 AM3/5/13
to am...@googlegroups.com

Hi Alessio88
I hope you are doing fine.
Can you please explain for me the meaning of your abbreviations because I am
trying to code your code in Cplex .. Or if you have it ready on Cplex Could
you please send it to me as soon as you can because I am in urgent need for
it

I do appreciate your help and support
Regards
Adel

alessio88 wrote:
>
> Hi, I'm using a VRP algorithm that gives me the perfect solution but it
> takes too much time to solve problems with more than 12 nodes. These are
View this message in context: http://old.nabble.com/VRP-algorithm-tp33850933p35088860.html

nockma...@gmail.com

unread,
Mar 28, 2016, 9:40:04 AM3/28/16
to AMPL Modeling Language, ales...@tiscali.it, nppl...@hotmail.com
Cplex model languages for VRP algorithm

Excuse me, could you please help me to change the this example from AMPL version to Cplex version??
Thank you very much.

เมื่อ วันอังคารที่ 22 พฤษภาคม ค.ศ. 2012 1 นาฬิกา 15 นาที 36 วินาที UTC+7, alessio88 เขียนว่า:

Robert Fourer

unread,
Mar 29, 2016, 10:09:37 AM3/29/16
to am...@googlegroups.com
We can help with solving your AMPL model, using CPLEX for AMPL, but; we are not prepared to offer help for other CPLEX software. You might be able to get more CPLEX help from IBM; try searching on "ibm cplex forums" for links to some websites that provide answers to user questions.

Bob Fourer
am...@googlegroups.com

=======

มณีรัตน์ การรักษ์

unread,
Mar 29, 2016, 11:15:22 AM3/29/16
to am...@googlegroups.com

Thanks you for your help me.

เมื่อ 29 มี.ค. 2016 21:09 "Robert Fourer" <4...@ampl.com> เขียนว่า:
--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/LQ2NeMqZxdI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.

To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

yenifer...@usc.edu.co

unread,
Apr 18, 2017, 10:36:01 PM4/18/17
to AMPL Modeling Language, ales...@tiscali.it, Carol Andrea Collazos Sanchez

La información de este mensaje y sus anexos son propiedad de la USC, es de uso exclusivo de su destinatario intencional y puede contener  información de carácter privado o confidencial. Cualquier revisión, retransmisión, divulgación,  copia  o  uso  indebido de este documento y/o sus anexos, está estrictamente prohibida y será sancionada legalmente.

Q Antes de imprimir este mensaje, asegúrate de que es necesario. Proteger el medio ambiente está también en tu mano.

Robert Fourer

unread,
Apr 19, 2017, 11:40:52 AM4/19/17
to am...@googlegroups.com
AMPL only describes models; it does not describe heuristic algorithms for solving. However a simple approach to using AMPL in a heuristic way is to set a time limit for the solver; then the solver will return the best solution it has found so far. or a problem with binary variables, this may even be the optimal solution, though you won't have a proof of optimality since the solver stopped at the time limit.

Each solver has its own options for setting a time limit, so you'll have to look them up on the appropriate solver page -- see http://ampl.com/products/solvers/.

Bob Fourer
am...@googlegroups.com

=======

From: am...@googlegroups.com [mailto:am...@googlegroups.com] On Behalf Of yenifer...@usc.edu.co
Sent: Tuesday, April 18, 2017 3:35 PM
To: AMPL Modeling Language
Reply all
Reply to author
Forward
0 new messages