简介
GMAS的输出包含以下几部分: 1. 编译结果 编译结果包含输入文件的打印,可能的错误提示以及GMAS对象和交叉引用图列表。 2. 执行结果 执行结果包含展示声明的结果和可能的执行错误提示。 3. 模型生成 该结果在模型生成过程给出,包含等式和变量列表以及模型统计和可可能的生成执行时的错误提示。 4. 解 外部求解器程序处理模型时生成的解报告包括:求解总结,求解器的报告,解列表以及报告总结。 5. 解后输出 输出的最后部分包括最终执行总结和文件总结。
模型示例
1 | $Title A Quadratic Programming Model for Portfolio Analysis (ALAN,SEQ=124a) |
1.编译输出
该结果在程序初始检查时生成。包括:输入文件的打印,符号引用图,符号清单图,特殊元素清单图和包含的文件总结。 ## 1.1 输入文件的打印 基本就是把输入的模型文本重新打印一遍。 1
2
3
4
5
6
7
8
9
10A Quadratic Programming Model for Portfolio Analysis (ALAN,SEQ=124a)
C o m p i l a t i o n
2
4
This is a mini mean-variance portfolio selection problem described in
'GAMS/MINOS:Three examples' by Alan S. Manne, Department of Operations
Research, Stanford University, May 1986.
10
11 * This model has been modified for use in the documentation1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
4012
13 Set i securities /hardware, software, show-biz, t-bills/;
14 alias (i,j);
15
16 Scalar target target mean annual return on portfolio % /10/,
17 lowyield yield of lowest yielding security,
18 highrisk variance of highest security risk ;
19
20 Parameters mean(i) mean annual returns on individual securities (%)
21 / hardware 8
22 software 9
23 show-biz 12
24 t-bills 7 / ;
25
26 Table v(i,j) variance-covariance array (%-squared annual return)
27 hardware software show-biz t-bills
28 hardware 4 3 -1 0
29 software 3 6 1 0
30 show-biz -1 1 10 0
31 t-bills 0 0 0 0 ;
32
33 lowyield = smin(i, mean(i)) ;
34 highrisk = smax(i, v(i,i)) ;
35 display lowyield, highrisk ;
36
37 Variables x(i) fraction of portfolio invested in asset i
38 variance variance of portfolio ;
39 Positive Variable x ;
40
41 Equations fsum fractions must add to 1.0
42 dmean definition of mean return on portfolio
43 dvar definition of variance;
44
45 fsum.. sum(i, x(i)) =e= 1.0;
46 dmean.. sum(i, mean(i)*x(i)) =e= target;
47 dvar.. sum(i, x(i)*sum(j,v(i,j)*x(j))) =e= variance;
48
49 Model portfolio / fsum, dmean, dvar / ;
50 Solve portfolio using nlp minimizing variance;
51 display x.l, variance.l;
1.2 符号引用图
1 | Symbol Listing |
头两列给出了符号的名字和类型。数据类型和简写如下:
Shorthand Symbol | GAMS Data Type |
---|---|
ACRNM | acronym |
EQU | equation |
FILE | put file |
MODEL | model |
PARAM | parameter |
SET | set |
VAR | variable |
后面几列会给出符号在第几行声明(declared),在第几行隐式的制定,第几行被引用。 1
2
3declared 37
impl-asn 50
ref 39 45 46 2*47 51
Shorthand Symbol | Reference Type | Description |
---|---|---|
declared | Declaration | The identifier is declared as to type. This must be the first appearance of the identifier. |
defined | Definition | An initialization (for a table or a data list between slashes) or symbolic definition (for an equation) starts for the identifier. |
assigned | Assignment | Values are replaced because the identifier appears on the left-hand side of an assignment statement. |
impl-asn | Implicit Assignment | An equation or variable will be updated as a result of being referred to implicitly in a solve statement. |
control | Control | A set is used as (part of) the driving index in an assignment, equation, loop or indexed operation. |
ref | Reference | The symbol has been referenced on the right-hand side of an assignment or in a display, equation, model, solve statement or put statetement. |
index | Index | Like control, but used only for set labels. Appears only in the cross reference map of unique elements. See section The Unique Element Listing Map for details. |