Initializing help system before first use

Making the Minimum Mandatory Changes

The code sample in this section shows the effect of applying the minimal set of changes to the example code.
Within Xpress Workbench, change your foliodata.mos file so that it now appears as:
01:(!
02:    File Type: Mosel model.
03:    Purpose: mminsight Mosel module example: Portfolio optimization app.
04:    (c) 2020 Fair Isaac Corporation.
05:!)
06:model "Portfolio Optimization with Mosel"
07:    version 1.0.0
08:
09:    options noimplicit
10:	   uses "mminsight"
11:    uses "mmxprs"
12:    uses "mmsystem"
13:
14:    public declarations
15:        ! Input entities
16:        MaxHighRisk: real
17:        MaxPerShare: real
18:        MinNorthAmerica: real
19:        ShareIds: set of string
20:
21:        ! Input and result entities indexed over ShareIds
22:        Shares_Return: array (ShareIds) of real
23:        Shares_HighRisk: array (ShareIds) of boolean
24:        Shares_NorthAmerica: array(ShareIds) of boolean
25:        Shares_fraction: array(ShareIds) of mpvar
26:
27:        ! Result entities
28:        TotalReturn: linctr
29:        SummaryIds: set of string
30:        SummaryValues: array (SummaryIds) of real
31:
32:        ! Constant<
33:        DATAFILE = "shares.csv"
34:    end-declarations
35:
36:    
37:    procedure read_data
38:        writeln("Loading data.")
39:        MaxHighRisk := 0.33  ! Max. investment into high-risk values
40:        MaxPerShare := 0.25    ! Max. investment per share
41:        MinNorthAmerica := 0.45				! Min. investment into N.-American values
42:
43:        initializations from "mmsheet.csv:skiph;" + DATAFILE
44:            [Shares_Return, Shares_HighRisk, Shares_NorthAmerica] as '[A:D]'
45:        end-initializations
46:
47:        writeln("Loading finished.")
48:    end-procedure
49:
50:    procedure solve_model
51:        declarations
52:            LimitHighRisk, LimitNorthAmerica 
					 : linctr
53:        end-declarations
54:
55:        writeln('Starting optimization.')
56:
57:        ! Objective: expected total return
58:        TotalReturn := sum (s in ShareIds) Shares_Return(s) * Shares_fraction(s)
59:
60:        ! Limit the percentage of high-risk values
61:        LimitHighRisk :=
62:            sum (s in ShareIds | Shares_HighRisk(s)) Shares_fraction(s) <= MaxHighRisk
63:
64:        ! Minimum amount of North-American values
65:        LimitNorthAmerica 
					  :=
66:            sum (s in ShareIds | Shares_NorthAmerica(s)) Shares_fraction(s) >= MinNorthAmerica
67:
68:        ! Spend all the capital
69:        sum (s in ShareIds) Shares_fraction(s) = 1
70:
71:        ! Upper bounds on the investment per share
72:        forall (s in ShareIds) do
73:            Shares_fraction(s) <= MaxPerShare
74:        end-do
75:
76:        ! Solve optimization problem
77:        insightmaximize(TotalReturn)
78:
79:        ! Save key indicator values for GUI display
80:        SummaryValues("Expected total return") := TotalReturn.sol
81:        SummaryValues("Total high risk shares") := LimitHighRisk.act
82:        SummaryValues("Total North-American") := LimitNorthAmerica 
					 .act
83:        SummaryValues("Largest position") := max (s in ShareIds) Shares_fraction(s).sol
84:
85:        forall (SummaryId in SummaryIds) do
86:            writeln(formattext("%-23s%7.2f", SummaryId, SummaryValues(SummaryId)))
87:        end-do
88:
89:        writeln('Optimization finished.')
90:    end-procedure
91:
92:    case insightgetmode of
93:        INSIGHT_MODE_LOAD: do
94:            read_data
95:        end-do
96:
97:        INSIGHT_MODE_RUN: do
98:            insightpopulate
99:            solve_model
100:       end-do
101:    else
102:        read_data
103:        solve_model
104:    end-case
105:
105:end-model

Commentary

Line 10 loads the mminsight package.

Line 77 now contains a call to insightmaximize instead of maximize.

Lines 92-104 contain the LOAD and RUN mode code. If Xpress Insight is loading data, then read_data is called (line 94.) If it is starting a run, then insightpopulate and solve_model are called (line 98 & 99 .) If neither of these is true (i.e. the model is running in non-Xpress Insight mode) then read_data and solve_model are called.

© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.