Display Model
If you choose the Display model option of the Solver|Generate command, LINGO will place a copy of the generated model in a new window, which you may scroll through to examine, print, or save to disk.
As an example of the output from the Generate command, consider the transportation model developed in Chapter 1:
MODEL:
! A 6 Warehouse 8 Vendor Transportation Problem;
SETS:
WAREHOUSES: CAPACITY;
VENDORS: DEMAND;
LINKS( WAREHOUSES, VENDORS): COST, VOLUME;
ENDSETS
DATA:
!set members;
WAREHOUSES = WH1 WH2 WH3 WH4 WH5 WH6;
VENDORS = V1 V2 V3 V4 V5 V6 V7 V8;
!attribute values;
CAPACITY = 60 55 51 43 41 52;
DEMAND = 35 37 22 32 41 32 43 38;
COST = 6 2 6 7 4 2 5 9
4 9 5 3 8 5 8 2
5 2 1 9 7 4 3 3
7 6 7 3 9 2 7 1
2 3 9 5 7 2 6 5
5 5 2 2 8 1 4 3;
ENDDATA
! The objective;
[OBJECTIVE] MIN = @SUM( LINKS( I, J):
COST( I, J) * VOLUME( I, J));
! The demand constraints;
@FOR( VENDORS( J): [DEMAND_ROW]
@SUM( WAREHOUSES( I): VOLUME( I, J)) =
DEMAND( J));
! The capacity constraints;
@FOR( WAREHOUSES( I): [CAPACITY_ROW]
@SUM( VENDORS( J): VOLUME( I, J)) <=
CAPACITY( I));
END
Model: WIDGETS
The objective will generate one expression, there should be one demand constraint generated for each of the eight vendors and one supply constraint generated for each of the six warehouses, for a grand total of 15 rows in the expanded model. Running the generate command to verify this reveals the following report:
MODEL:
[OBJECTIVE] MIN= 6 * VOLUME_WH1_V1 + 2 * VOLUME_WH1_V2 + 6 *
VOLUME_WH1_V3 + 7 * VOLUME_WH1_V4 + 4 * VOLUME_WH1_V5 + 2 *
VOLUME_WH1_V6 + 5 * VOLUME_WH1_V7 + 9 * VOLUME_WH1_V8 + 4 *
VOLUME_WH2_V1 + 9 * VOLUME_WH2_V2 + 5 * VOLUME_WH2_V3 + 3 *
VOLUME_WH2_V4 + 8 * VOLUME_WH2_V5 + 5 * VOLUME_WH2_V6 + 8 *
VOLUME_WH2_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DEMAND_ROW_V5] VOLUME_WH1_V5 + VOLUME_WH2_V5 +
VOLUME_WH3_V5 + VOLUME_WH4_V5 + VOLUME_WH5_V5 +
VOLUME_WH6_V5 = 41 ;
[DEMAND_ROW_V6] VOLUME_WH1_V6 + VOLUME_WH2_V6 +
VOLUME_WH3_V6 + VOLUME_WH4_V6 + VOLUME_WH5_V6 +
VOLUME_WH6_V6 = 32 ;
[DEMAND_ROW_V7] VOLUME_WH1_V7 + VOLUME_WH2_V7 +
VOLUME_WH3_V7 + VOLUME_WH4_V7 + VOLUME_WH5_V7 +
VOLUME_WH6_V7 = 43 ;
[DEMAND_ROW_V8] VOLUME_WH1_V8 + VOLUME_WH2_V8 +
VOLUME_WH3_V8 + VOLUME_WH4_V8 + VOLUME_WH5_V8 +
VOLUME_WH6_V8 = 38 ;
[CAPACITY_ROW_WH1] VOLUME_WH1_V1 + VOLUME_WH1_V2 +
VOLUME_WH1_V3 + VOLUME_WH1_V4 + VOLUME_WH1_V5 +
VOLUME_WH1_V6 + VOLUME_WH1_V7 + VOLUME_WH1_V8 <= 60 ;
[CAPACITY_ROW_WH2] VOLUME_WH2_V1 + VOLUME_WH2_V2 +
VOLUME_WH2_V3 + VOLUME_WH2_V4 + VOLUME_WH2_V5 +
VOLUME_WH2_V6 + VOLUME_WH2_V7 + VOLUME_WH2_V8 <= 55 ;
[CAPACITY_ROW_WH3] VOLUME_WH3_V1 + VOLUME_WH3_V2 +
VOLUME_WH3_V3 + VOLUME_WH3_V4 + VOLUME_WH3_V5 +
VOLUME_WH3_V6 + VOLUME_WH3_V7 + VOLUME_WH3_V8 <= 51 ;
[CAPACITY_ROW_WH4] VOLUME_WH4_V1 + VOLUME_WH4_V2 +
VOLUME_WH4_V3 + VOLUME_WH4_V4 + VOLUME_WH4_V5 +
VOLUME_WH4_V6 + VOLUME_WH4_V7 + VOLUME_WH4_V8 <= 43 ;
[CAPACITY_ROW_WH5] VOLUME_WH5_V1 + VOLUME_WH5_V2 +
VOLUME_WH5_V3 + VOLUME_WH5_V4 + VOLUME_WH5_V5 +
VOLUME_WH5_V6 + VOLUME_WH5_V7 + VOLUME_WH5_V8 <= 41 ;
[CAPACITY_ROW_WH6] VOLUME_WH6_V1 + VOLUME_WH6_V2 +
VOLUME_WH6_V3 + VOLUME_WH6_V4 + VOLUME_WH6_V5 +
VOLUME_WH6_V6 + VOLUME_WH6_V7 + VOLUME_WH6_V8 <= 52 ;
END
Model: Generated Model Report for WIDGETS
As expected, there are 15 rows in the generated model: [OBJECTIVE], [DEMAND_ROW_V1] through [DEMAND_ROW_V8], and [CAPACITY_ROW_WH1] through [CAPACITY_ROW_WH6].
As a side note, it’s interesting to compare the generated model to the original, set-based model. The generated model is the expanded version of the model, and has all sets and vector variables removed, resulting in a fully scalar model. The scalar-based, generated model is mathematically equivalent to the original vector-based model. However, we think most would agree that the set-based model is much easier to comprehend, thereby illustrating one of the primary benefits of modern algebraic languages over more traditional, scalar-based languages.
In addition to verifying that the correct number of rows is being generated, you should also examine each of the rows to determine that the correct variables are appearing in each row along with their correct coefficients.
Note: | The reports generated by the Solver|Generate command are valid LINGO models. You may load Generate reports into a model window and solve them as you would any other LINGO model. |
One thing to keep in mind when examining generated model reports is that the LINGO model generator performs fixed variable reduction. This means that any variables that are fixed in value are substituted out of the generated model. For example, consider the simple model:
MODEL:
MAX = 200 * WS + 300 * NC;
WS = 60;
NC <= 40;
WS + 2 * NC <= 120;
END
If we generate this model we get the following, reduced model:
MODEL:
MAX= 300 * NC + 12000 ;
NC <= 40 ;
2 * NC <= 60 ;
END
At first glance, it seems as if both the first constraint and the variable WS are missing from the generated model. Note that by the first constraint in the original model (WS = 60), WS is fixed at a value of 60. The LINGO model generator exploits this fact to reduce the size of the generated model by substituting WS out of the formulation. The final solution report will still contain the values for all the fixed variables, however, the fixed variables will not appear in the generated model report. If you would like to suppress fixed variable reduction so that all variables appear in your generated model, you may do so via the Fixed Var Reduction option.