建模0—1规划
- 格式:doc
- 大小:27.50 KB
- 文档页数:2
SETS:
!We have a network of 10 points.
We want to find the length of the shortest route
from point 1 to point 10.;
! Here is our primitive set of 10 points,where
F(i) represents the shortest path distance
from point i to the last point;
CITIES /1..10/:F;
! The derived set ROADS lists the roads that
exist between the points;
ROADS(CITIES,CITIES)/
1,2 1,3 1,4
2,5 2,6
3,5 3,6 3,7
4,6 4,7
5,8 5,9
6,8 6,9
7,8 7,9
8,10
9,10/:D;
! D(i,j) is the distance from point i to j;
ENDSETS
DATA:
! Here are the distances that correspond to the above links;
D=
4.5 2.8 3
10.3 9
6 7.4 10.2
3.5 8.3
4.6 8.2
9 6.5
5.4 4.6
8
4.6;
ENDDATA
! If you are already in point 10,then the cost to
travel to point 10 is 0;
F(@SIZE(CITIES))=0;
@FOR(CITIES(i)|i#LT#@SIZE(CITIES):
F(i)=@MIN(ROADS(i,j):D(i,j)+F(j))
);
END
SETS:
!We have a network of 10 points.
We want to find the length of the shortest route
from point 1 to point 10.;
! Here is our primitive set of 10 points,where
F(i) represents the shortest path distance
from point i to the last point;
CITIES /1..10/:F;
! The derived set ROADS lists the roads that
exist between the points;
ROADS(CITIES,CITIES)/
1,2 1,3 1,4
2,5 2,6
3,5 3,6 3,7
4,6 4,7
5,8 5,9
6,8 6,9
7,8 7,9
8,10
9,10/:D;
! D(i,j) is the distance from point i to j;
ENDSETS
DATA:
! Here are the distances that correspond to the above links;
D=
4.5 2.8 3
10.3 9
6 7.4 10.2
3.5 8.3
4.6 8.2
9 6.5
5.4 4.6
8
4.6;
ENDDATA
! If you are already in point 10,then the cost to
travel to point 10 is 0;
F(@SIZE(CITIES))=0;
@FOR(CITIES(i)|i#LT#@SIZE(CITIES):
F(i)=@MIN(ROADS(i,j):D(i,j)+F(j))
);
END