Download presentation
Presentation is loading. Please wait.
1
LINGO
2
LINGO 起始畫面
3
示範例題 Max = 160*X1 + 100*X2 + 250*X3 s.t. X1 + X3 <= 4
X1, X2, X3 為整數 (integer)
4
答案求解 開始求解
5
模式建立 每一條式子都需要以分號 ; 作結尾 目標函數 - Max or Min 限制式 變數定義 - @BIN、@GIN 答案輸出
the general integer variable domain function A binary integer variable - also called a 0/1 variable 每一條式子都需要以分號 ; 作結尾
6
模式建立 目標函數 限制式 變數定義
7
結果輸出 最佳解之 目標函數值 最佳解之 變數值
8
SETS LINGO allows you to group many instances of the same variable into sets. For example, if a model involved 27 delivery trucks, then these 27 trucks could be described more simply as a single set. Sets may also include attributes for each member, such as the hauling capacity for each delivery truck.
9
Example SETS: Trucks/TR1..TR27/:Capacity; ENDSETS
The attributes for each member are called “Capacity.”
10
set looping functions @FOR – generates constraints over members of a set. @SUM – sums an expression over all members of the set. @MIN – computes the minimum of an expression over all members of the set. @MAX – computes the maximum of an expression over all members of the set.
11
Example @FOR(Trucks(T): Capacity(T)<=3000);
Capacity(J)); MIN_HAUL Capacity(J)); MAX_HAUL Capacity(J));
12
The LINGO Data Section SETS: SET1 /A, B, C/: X, Y; ENDSETS DATA:
ENDDATA
13
Example SETS: ITEMS / ANT_REPEL, BEER, BLANKET, BRATWURST, BROWNIES, FRISBEE, SALAD, WATERMELON/ : INCLUDE, WEIGHT, RATING; ENDSETS DATA: WEIGHT RATING = 1 2 3 9 4 3 3 8 3 10 1 6 5 4 10 10; KNAPSACK_CAPACITY = 15; ENDDATA MAX ITEMS: RATING * INCLUDE); @SUM( ITEMS: WEIGHT * INCLUDE) <= KNAPSACK_CAPACITY; @FOR( INCLUDE));
Similar presentations