Discrete Optimization in Flexible Manufacturing Systems Laboratory
Discrete Optimization in Flexible Manufacturing Systems Laboratory
Discrete Optimization in Flexible Manufacturing Systems Laboratory
Contents:
1. Lingo commands
2. Lingo examples
3. Simple discrete optimization examples
4. FMS loading and routing example
LINGO Page 1
1 Lingo commands
∀j ∈ C ∑
i∈W
v ij ≥dj
1.2 Statements
♦ Each statement must terminated by a semicolon.
♦ Each statement specifies a condition that the variables must satisfy
rather than a computational rule for computing a variable.
♦ Lingo disregards case, y and Y for example is the same variable.
♦ Comments start with „!” and finish with semicolon „;”.
♦ Statement names, e.g. @FOR( Days(d):[Overtime] Hours(d) < 12 );
[Total cost objective] MIN = @SUM( Days: Hours*HourCost)
1.3 Sets
♦ Primitive sets: set_name /domain/ [: variables];
♦ Domain definition by explicit list is used when set elements are called by name in model
description, e.g.
SETS:
Days / Mo, Tu, We, Th, Fr, Sa, Su/ : Hours;
ENDSETS
Hours(Mo) > Hours(Tu) + Hours(We)
♦ Domain definition by range is for large vectors, e.g. /1..10/.
♦ Derived sets are used for multi-dimensional vectors, e.g. matrices
set_name (list_of_parent_sets) [: variables];
♦ Sparse (not dense) sets are used to exclude some elements of derived sets:
set_name (list_of_parent_sets) | /explicit list/ [:
variables]; or
set_name (list_of_parent_sets) | condition [: variables]; e.g.
SETS:
Operations /1..5/;
Sequence (Operations, Operations) | ( 1,2 2,3 3,4 3,5 4,5 );
AllPairs (Operations, Operations) | &1 #GT# &2;
ENDSETS
3
1 2 5
4
Page 2 LINGO
1.4 Variables
♦ Continuous, non-negative.
♦ @BIN() command declares variables as binary.
♦ @GIN() command declares variables as integer and positive.
♦ @FREE() command declares variables as binary negative or positive.
♦ @BND() command declares lover and upper bound for a variable, e.g. @BND(-5,x,5).
1.7Other functions
♦ @MIN(), @MAX(), @ABS(), @EXP(), @LOG(), @SIN(), @COS(),
@TAN()...
LINGO Page 3
2 Lingo examples
2.1 PC Mix
MODEL:
! Total profit for the week;
MAX = 200 * WS + 300 * NC;
model:
! The objective;
[OBJ] MIN = @SUM( ROUTES: COST * VOLUME);
end
Page 4 LINGO
MODEL:
SETS:
FLIGHT/1..3/; ! There are three flights;
GATE/1..4/; ! There are five gates;
FXG( FLIGHT, GATE): X; !Flight-gate assignment;
GXG( GATE, GATE): T; !Distance between gates;
FXF( FLIGHT, FLIGHT): N; !Transfers btwn flights;
ENDSETS
DATA:
N = 0 30 5 ! No. transfers between flights;
20 0 0
30 40 0 ;
SETS:
! Transfer between 2 flights must be required and related to 2 different
gates. Warning: this set gets big fast.;
TGTG( FLIGHT, GATE, FLIGHT, GATE)|
&1 #LT# &3 #AND# (( N( &1, &3) #NE# 0) #AND#
( T( &2, &4) #NE# 0) #OR# ( N( &3, &1) #NE# 0)
#AND# ( T( &4, &2) #NE# 0)): Y;
ENDSETS
END
LINGO Page 5
MODEL:
SETS:
! Dynamic programming illustration (see Anderson, Sweeney & Williams, An
Intro to Mgt Science, 6th Ed.). We have a network of 10 cities. We want to
find the length of the shortest route from city 1 to city 10.;
! The derived set ROADS lists the roads that exist between the cities (note:
not all city pairs are directly linked by a road, and roads are assumed to
be one way.);
ROADS( CITIES, CITIES)/
1,2 1,3 1,4
2,5 2,6 2,7
3,5 3,6 3,7
4,5 4,6
5,8 5,9
6,8 6,9
7,8 7,9
8,10
9,10/: D;
! D( i, j) is the distance from city i to j;
ENDSETS
DATA:
! Here are the distances that correspond to the above links;
D =
1 5 2
13 12 11
6 10 4
12 14
3 9
6 5
8 10
5
2;
ENDDATA
! If you are already in City 10, then the cost to travel to City 10 is 0;
F( @SIZE( CITIES)) = 0;
END