1. 程式人生 > >清華大學肖勇波樑湧老師的巨集篇譯著中的問題實踐之004-生產計劃問題與投資問題

清華大學肖勇波樑湧老師的巨集篇譯著中的問題實踐之004-生產計劃問題與投資問題

清華大學肖勇波樑湧老師的巨集篇譯著中的問題實踐之004-生產計劃問題與投資問題

清華大學肖勇波樑湧老師翻譯的Rardin教授的《運籌學》[1]已於今年年中出版,感謝機械工業出版社張有利老師的推薦和贈書。

問題

生產計劃問題和投資問題見原書第二章的兩個練習,習題2-1和習題2-2。

生產計劃問題又叫混合生產問題(Mixed Production Problem),是經典的線型規劃問題。

投資問題又叫投資組合問題,是金融背景上的一種揹包問題。

+Leapms生成的兩個問題的模型摘錄

對任何問題,+Leapms都建議直接用+Leapms建模語言直接寫出模型,並進行模型除錯。

我們的經驗是,模型除錯能夠發現模型的不足、促進建模的完美性,甚至可以促進對問題的更加深入的瞭解。當模型除錯完畢,對模型的正確性有充分的信心後,+Leapms系統可生成模型摘錄,包括數學概念模型(即使用標引符號表示的數學模型)和+Leapms原始碼供交流使用。

以下是兩個問題的+Leapms模型摘錄(pdf螢幕截圖), 其中 模型"02-1.leap" 是生產計劃問題, 模型"02-02"是投資問題:

求解過程

+Leapms>load
 Current directory is "ROOT".
 .........
        02-01.leap
        02-02.leap
        02-03.leap
        02-39.leap
 .........
please input the filename:02-01
================================================================
1
: //2-1 The Notip Table Company sells two models of its patented 2: //five-leg tables. The basic version uses a wood top, requires 3: //0.6 hour to assemble, and sells for a profit of $200. The 4: //deluxe model takes 1.5 hours to assemble because of its glass 5: //top, and sells for a profit of $350. Over the next week the
6: //company has 300 legs, 50 wood tops, 35 glass tops, 7: //and 63 hours of assembly available. Notip wishes 8: //to determine a maximum profit production plan 9: //assuming that everything produced can be sold. 10: 11: max sum{j=1,..,n}c[j]x[j] 12: subject to 13: sum{j=1,..,n}a[i][j]x[j]<=b[i] | i=1,..,m 14: where 15: m,n are integers 16: b[i] is a number|i=1,..,m 17: c[j] is a number|j=1,..,n 18: a[i][j] is a number|i=1,..,m;j=1,..,n 19: x[j] is a variable of nonnegative number --> 20: |j=1,..,n 21: data 22: m=4 // number of kinds of resources 23: n=2 // number of product 24: c={200 350} // profits 25: b={63 300 50 35} //availabilities 26: a={ 27: 0.6 1.5 //hours 28: 5 5 //legs 29: 1 0 //wood tops 30: 0 1 //glass tops 31: } ================================================================ >>end of the file. Parsing model: 1D 2R 3V 4O 5C 6S 7End. .................................. number of variables=2 number of constraints=4 .................................. +Leapms>solve The LP is solved to optimal. 找到線性規劃最優解.非零變數值和最優目標值如下: ......... x1*=30 x2*=30 ......... Objective*=16500 ......... +Leapms>load Current directory is "ROOT". ......... 02-01.leap 02-02.leap 02-03.leap 02-39.leap ......... please input the filename:02-02 ================================================================ 1: //2-2 Wiley Wiz is a mutual fund manager trying to 2: //decide how to divide up to $12 million between 3: //domestic and foreign stocks. Domestic stocks 4: //have been returning 11% per year and foreign 5: //17%. Naturally, Wiley would like to maximize 6: //the annual return from his investments. Still, he 7: //wants to exercise some caution. No more that $10 8: //million of the fund should go into domestic stocks 9: //and no more than $7 million into foreign. Also, at 10: //least half as much should be invested in foreign as 11: //domestic, and at least half as much in domestic as 12: //foreign to maintain some balance. 13: 14: max sum{i=1,..,m}R[i]x[i]/100 15: subject to 16: sum{i=1,..,m}x[i]<=T 17: x[i]<=B[i] | i=1,..,m 18: where 19: m is an integer 20: T is a number 21: R[i],B[i] are numbers|i=1,..,m 22: x[i] is a variable of nonnegative number--> 23: |i=1,..,m 24: data 25: m=2 26: T=12 27: R={11 17} 28: B={10 7} ================================================================ >>end of the file. Parsing model: 1D 2R 3V 4O 5C 6S 7End. .................................. number of variables=2 number of constraints=3 .................................. +Leapms>solve The LP is solved to optimal. 找到線性規劃最優解.非零變數值和最優目標值如下: ......... x1*=5 x2*=7 ......... Objective*=1.74 ......... +Leapms>

參考文獻

 [1] Rardin R. L 著,肖勇波、樑湧譯. 運籌學. 北京:機械工業出版社,2018