Initializing help system before first use

Code Samples - Using the View Designer to create custom views

Your project folder must contain two subfolders named attachments and model_resources.

Project Folder

foliodata.mos
model "Portfolio optimization with LP"
    uses "mminsight" ! For Xpress Insight
    uses "mmxprs" ! Use Xpress-Optimizer
        parameters
        DATAFILE= "folio.dat" ! File with problem data
        OUTFILE= "result.dat" ! Output file
        MAXRISK = 1/3 ! Max. investment into high-risk values
        MAXVAL = 0.3 ! Max. investment per share
        MINAM = 0.5 ! Min. investment into N.-American values
    end-parameters
    public declarations
        !@insight.manage input
        !@insight.alias Set of all shares
        SHARES: set of string ! Set of shares
        !@insight.manage input
        !@insight.alias Set of high risk shares
        RISK: set of string ! Set of high-risk values among shares
        !@insight.manage input
        !@insight.alias Set of all North American shares
        NA: set of string ! Set of shares issued in N.-America
        !@insight.manage input
        !@insight.alias Estimated ROI per share
        RET: array(SHARES) of real ! Estimated return in investment
        !@insight.manage input
    changeShare: string
    end-declarations

    forward procedure datainput

    case insightgetmode of
        INSIGHT_MODE_LOAD: do
                datainput
                exit(0)
            end-do
        INSIGHT_MODE_RUN:
            insightpopulate
            else
                datainput
    end-case
        procedure datainput
        initializations from DATAFILE
            RISK RET NA
        end-initializations
        changeShare:="brewery"
    end-procedure
    public declarations
        !@insight.manage result
        !@insight.alias Outcomes
        frac: array(SHARES) of mpvar
 							! Fraction of capital used per share
								SolReturn : real
    end-declarations
    ! Objective: total return
    Return:= sum(s in SHARES) RET(s)*frac(s)
    ! Limit the percentage of high-risk values
    sum(s in RISK) frac(s) <= MAXRISK
    ! Minimum amount of North-American values
    sum(s in NA) frac(s) >= MINAM
    ! Spend all the capital
    sum(s in SHARES) frac(s) = 1
    ! Upper bounds on the investment per share
    forall(s in SHARES) frac(s) <= MAXVAL

    ! Solve the problem
    insightmaximize(Return)
	   
				SolReturn:=round(getobjval*100)/100

		  ! Solution printing to a file
    fopen(OUTFILE, F_OUTPUT)
    writeln("Total return: ", getobjval)
    forall(s in SHARES)
    writeln(strfmt(s,-12), ": \t", strfmt(getsol(frac(s))*100,5,2), "%")
    fclose(F_OUTPUT)
end-model
foliodata.xml
<?xml version="1.0" encoding="UTF-8"?>
<model-companion xmlns="http://www.fico.com/xpress/optimization-modeler/model-companion" version="3.0">
<client>
    <view-group title="Portfolio Optimization">
        <vdl-view title="Portfolio" path="foliodata.vdl"></vdl-view>
    </view-group>
</client>
</model-companion>

model_resources folder

folio.dat
! Data file for `folio*.mos'
RET: [("treasury") 5 ("hardware") 17 ("theater") 26 ("telecom") 12
("brewery") 8 ("highways") 9 ("cars") 7 ("bank") 6
("software") 31 ("electronics") 21 ]
DEV: [("treasury") 0.1 ("hardware") 19 ("theater") 28 ("telecom") 22
("brewery") 4 ("highways") 3.5 ("cars") 5 ("bank") 0.5
("software") 25 ("electronics") 16 ]
NAMES: ["treasury" "hardware" "theater" "telecom" "brewery" "highways" "cars"
"bank" "software" "electronics"]
COUNTRY: ["Canada" "USA" "USA" "USA" "UK" "France" "Germany" "Luxemburg" "India"
"Japan"]
RISK: ["hardware" "theater" "telecom" "software" "electronics"]
NA: ["treasury" "hardware" "theater" "telecom"]

attachments folder

caution.txt
cautionText:"** Text to be replaced **"

© 2001-2019 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.