## Wrong Solution

Problems with modeling
brfnrt
User
Posts: 1
Joined: 2 months ago

### Wrong Solution

Hi, the code I wrote works, but the result is not correct. I don't know how to fix it. I added the output of the code. If you help, I'll be very much yours.
option optcr=0;
sets
i Turkiyedeki yedi bolge /1*7/
j Sinir disindaki askeri usler /1*11/
k Silah turu /1*15/;
variables
a(i,j) i. dugumden j. dugume atanacak asker miktari
x(i,j,k) i. dugumden j. dugume tasinan k silah turu miktari
z(i,j) i den j ye asker tasinmissa 1 dd 0
y(i) i den herhangi bir yere asker tasima olmussa 1 dd 0
e(i,j) i den j ye k silahı taşındıysa 1 dd 0
f(i) i den herhangi bir yere silah tasima olmussa 1 dd 0
p;
binary variables
z,e,y,f;
integer variables
a,x;
parameters
d(i,j)
t(i,j)
r(i,j)
n(j,k)
m(i,k)
c(i) i. bolgede bulunan gonderilebilecek asker miktari
/1 65, 2 299, 3 40400, 4 60, 5 240, 6 2400, 7 7650/
v(k) k silahinin agirligi kg
/1 0.969, 2 1, 3 0.8, 4 0.79, 5 2.7, 6 2.265, 7 4.25, 8 3.9, 9 3.1, 10 4.2, 11 4.2, 12 11.5, 13 38, 14 4.55, 15 6.4/
/1 250, 2 400, 3 100, 4 100, 5 40000, 6 5000, 7 2500, 8 300, 9 200, 10 70, 11 2000/;

table
d(i,j) i. bolge ile j. us arası mesafe km
1 2 3 4 5 6 7 8 9 10 11
1 1156 810 946 1476 1042 1460 2198 3637 7208 2069 4495
2 1636 1041 1177 1451 815 1436 2173 3612 7183 2428 4854
3 1853 1365 1501 1159 359 1144 1882 3321 6892 2079 4501
4 2214 1866 2001 1188 1146 1060 1369 2830 6920 948 3529
5 1768 1253 1389 1043 752 1027 1765 3204 6775 1718 4144
6 2600 2252 2388 760 847 489 848 2310 6492 1126 3379
7 2385 2036 2172 1075 1162 804 1112 2573 6807 847 3270;
table
t(i,j) i den j ye tasinabilecek max kg
1 2 3 4 5 6 7 8 9 10 11
1 610 633 395 276 77346 10936 3669 388 431 247 2534
2 546 613 318 290 73735 10747 4898 498 448 197 2594
3 647 730 356 257 76258 10628 3632 385 381 172 2423
4 542 718 316 274 74689 10024 3502 360 419 173 2582
5 688 578 383 373 72497 10156 4101 417 412 153 2377
6 622 667 323 353 74968 10570 4903 463 394 237 2348
7 627 697 334 361 74024 10874 3848 479 369 219 2470;

table
r(i,j) j. bolgeden i. usse giden yoldaki risk seviyesi
1 2 3 4 5 6 7 8 9 10 11
1 41 10 45 40 41 30 14 10 41 26 40
2 53 24 38 10 20 39 10 21 20 23 36
3 42 41 38 20 12 18 14 20 37 16 10
4 32 34 30 10 41 62 40 29 64 12 37
5 66 40 51 22 16 30 33 24 32 45 50
6 10 20 26 10 44 10 12 42 37 21 42
7 10 16 10 29 12 30 14 34 45 14 48;

table
m(i,k) i. bolgede bulunan k silahi miktari
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 344 915 1986 1028 2067 1201 2049 712 947 1256 1315 497 13 731 964
2 1174 987 1918 49 1539 1595 2044 346 121 478 907 711 8 1276 2785
3 986 51 1237 492 644 981 2441 549 853 535 1157 401 4 704 98
4 413 224 1453 451 1190 1453 2066 1136 500 24 79 698 11 395 2090
5 597 167 2844 1004 1532 1211 2588 1121 766 245 11 731 7 386 1101
6 883 82 2616 538 1363 852 1710 204 201 388 226 677 8 1011 407
7 1081 661 1516 484 1665 1696 590 1094 95 256 96 979 19 2037 2629;
;
table
n(j,k) j . ussun k silahi talebi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 10 16 12 6 7 11 3 13 10 15 7 10 3 14 12
2 6 14 13 19 28 16 3 12 5 28 2 10 1 12 9
3 9 5 6 7 5 6 4 9 3 3 4 5 2 4 6
4 8 3 9 9 4 8 5 7 2 6 6 3 1 10 7
5 895 736 2617 753 1761 1553 2216 892 801 2117 953 792 5 2209 2436
6 180 149 67 160 189 274 187 120 202 232 340 229 4 101 234
7 18 150 82 38 42 77 156 99 128 63 161 32 2 39 70
8 9 11 16 2 2 5 8 19 10 10 1 9 1 9 11
9 5 4 8 13 6 7 6 11 8 13 9 10 1 3 2
10 1 2 2 4 4 5 5 2 3 2 1 3 1 3 4
11 101 115 112 56 97 21 36 14 111 103 23 29 2 36 12;

equations
kapasite_silah
talep_silah1
talep_silah2
atama_silah
agirlik
risk
amac

;
kapasite_silah(i,k).. sum(j,x(i,j,k))=L=m(i,k)*f(i);
talep_silah1(j).. sum(i,e(i,j))=E=1;
talep_silah2(j).. sum((i,k),x(i,j,k))=E=sum(k,n(j,k));
agirlik(i,j).. sum(k,x(i,j,k)*v(k))=L=t(i,j);
risk.. sum((i,j),(z(i,j)*r(i,j)+e(i,j)*r(i,j)))=L=25*sum((i,j),z(i,j)+e(i,j));
amac.. sum(i,y(i)+f(i))=E=p;
atama_silah(i).. sum(j,e(i,j))=L=11*f(i);

solve askeriyoneylem using mip minimizing p
display a.L,z.L,y.L,x.L,e.L,f.L,risk.L,p.L

as a picture.

Fred
Posts: 257
Joined: 4 years ago

### Re: Wrong Solution

Hi,

Please have a look at point 2 of the forum rules: app.php/rules

Your code cannot be executed without manually fixing all the broken table formatting.

Fred