!@encoding CP1250 model TSP uses "mmxprs"; !gain access to the Xpress-Optimizer solver !sample declarations section declarations ! ... n=3!pocet obsluhovanych vrcholu + 1 vrch=1..n depo=0..n c:array(depo,depo)of real!distanční matice obsluhovanýc zákazníků x:array(depo,depo)of mpvar!proměnná u:array(depo) of mpvar!proměnná end-declarations c::[0.0,2.1,2.1,1.6, 1.0,0.0,0.5,0.6, 1.1,0.0,0.0,0.5, 0.0,1.5,1.5,0.0] forall (j in depo) sum (i in depo| i<>j) x(i,j)=1 forall (i in depo) sum (j in depo| i<>j) x(i,j)=1 forall (i in depo, j in vrch | i<>j) u(i)-u(j)+n*x(i,j)<=n-1 x(n,0)=1 forall (i in depo) u(i)>=0 forall (j in depo) u(j)>=0 forall (i in depo, j in depo| i<>j) x(i,j) is_binary ujeta_vzdalenost:=sum(i in depo, j in depo) c(i,j)*x(i,j) minimize (ujeta_vzdalenost) writeln("Minimalni ujeta vzdalenost je: ", getobjval," km") forall(i in vrch) do if(getsol(x(0,i))>0) then writeln(0, " -> ", i) p:=i m:=0 repeat j:=n+1 repeat j-=1 if(getsol (x(p,j))>0)then writeln(p, " -> ", j) p:=j m:=m+1 end-if until j=0 until m=n end-if end-do end-model