Doubt VRP code

16 views
Skip to first unread message

María Vargas Magán

unread,
Apr 28, 2024, 8:24:46 PMApr 28
to AMPL Modeling Language
Hello, I'm writing the following code for the problem attached in the photo (I've taken v(S)=2) and I'm getting an error. Can someone help me?

param n:=7;
param m:=2;

set V := 1..n;
set Vprima := 2..n;
set A := {(i,j) in V cross V : i < j};
set NOT := {(i,j) in Vprima cross Vprima : i != j};
param c{1..n,1..n};

set S := 0 .. n - 1;
set SS := 0 .. 2**n - 1;
set POW {k in SS} := {i in S: (k div 2**i) mod 2 = 1};


let c[1,2]:=1;  
let c[1,3]:=6;  
let c[1,4]:=2;  
let c[1,5]:=2;  
let c[1,6]:=5;
let c[1,7]:=1;


let c[2,3]:=2;
let c[2,4]:=6;  
let c[2,5]:=2;  
let c[2,6]:=8;
let c[2,7]:=9;



let c[3,4]:=1;  
let c[3,5]:=6;  
let c[3,6]:=6;
let c[3,7]:=9;


let c[4,5]:=8;  
let c[4,6]:=10;
let c[4,7]:=11;



let c[5,6]:=2;
let c[5,7]:=4;


let c[6,7]:=1;



var x{Vprima,Vprima}, binary;
 

minimize Costo: sum{(i,j) in A} c[i,j] * x[i,j];
subject to R0 {j in V}:
    x[1, j] in {0, 1, 2};
subject to R1: sum{j in 2..n} x[1, j] = 2 * m;
subject to R2 {k in 2..n}:
    sum{(i,j) in A} x[i, k] + sum{(i,j) in A} x[k, j] = 2;
subject to R3:
    sum{i in S, j in S} x[i, j] <= card(S) - 2;

Thanks!!!
2024-04-28 (12).png

AMPL Google Group

unread,
Apr 29, 2024, 8:10:11 PMApr 29
to AMPL Modeling Language
Your question has been moved to our new user forum at discuss.ampl.com, and a response has been posted there. To see the response, use this link:

https://discuss.ampl.com/t/ampl-25036-doubt-vrp-code/1077/2

To reply, click the red "Reply" button that follows the response. (Do not send an email reply to this message.)


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2582741262-124210#}
Reply all
Reply to author
Forward
0 new messages