Hi to everyone,
i'm trying to solving this problem:
I have the position of n city, each city has the same distances. what I have to do is go through all the cities and return to the starting point.
This problem is a travelling salesman problem and my question is, is possible to resolve it?
Righ now i have created this program:
TSP.DAT:
### SET###
set CITY1;
set CITY2;
### PARAM###
param dist_city{
CITY1 ,
CITY2} >= 0 integer;
param pos_city{
CITY1 ,
CITY2} >= 0 integer;
param city_tot = 10;
### VAR ###
var x{i in
CITY1 , j in
CITY2} >= integer;
### CONSTRAINT ###
subject to sum_city {i in
CITY1 , j in
CITY2}: b[i,j] = city_tot;
### OBJ ###
minimize final_dist: sum{i in
CITY1 , j in
CITY2} dist_city[i,j];
TSP.DAT:
### VALUE OF SET ###
set
CITY1 := 1 2 3 4 5 6;
set
CITY2 := 1 2 3 4;
### VALUE FOR PARAM ###
param pos_city:
1 2 3 4 5 6 :=
1 0 1 1 1 1 0
2 0 1 1 1 1 0
3 0 1 1 1 1 0
4 0 0 0 0 0 0 ;
param dis_city:
1 2 3 4 5 6 :=
1 0 1 1 1 1 0
2 0 1 1 1 1 0
3 0 1 1 1 1 0
4 0 0 0 0 0 0 ;
TSP.RUN:
reset;
option solver gurobi;
model TSP.mod;
data TSP.dat;
solve;
display x;
display
final_dist ;
Let me explain what i have done:
-starting form TSP.DAT, i've thought of creating a matrix pos_city where the city are (are indicated with 1, with 0 no city) and the matrix dist_city (this 2 matrix are identical).
-meanwhile TSP.MOD, i considered the constraint where i want to pass in every single city.
But i think that my view is to simple and not accurate.
What do you think? Is a solvable problem?
Thak you for your time,
Jhon Lotus.