FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Output formatting for a transportation model

  • small LP problem
  • generate a nice printed output
  • using dynamic arrays for representing sparse data structures
  • reading several data arrays from a single data file
Further explanation of this example: 'Mosel User Guide', Section 3.2 A transport example and Section 10.1 Producing formatted output.

The section 'Traditional embedding: solving multiple scenarios' of the Xpress Whitepaper 'Embedding Optimization Algorithms' describes how to embed a similar transportation model into an application.

Source Files

Data Files


<vdl version="4.7">
    <!-- 'vdl' and 'vdl-page' must always be present -->
        <!-- 'header' element: container for any vdl elements that are not part 
             of the page layout -->
         <!-- Optional style definition -->
                 .Strong {
                     font-weight: bold;
                     font-style: italic;
        <!-- Placeholder message -->
	<vdl-container vdl-if="=!scenario.summaryData.hasResultData">
            <span vdl-text="No results available. Run the scenario to see the results." 

        <!-- Structural element 'section': 
             if hasResultData: display data once result values become available 
                              (after scenario execution) -->
        <vdl-section heading="Transportation Plan" vdl-if="=scenario.summaryData.hasResultData">

            <!-- Structural element 'row': arrange contents in rows -->
                <!-- Several columns within a 'row' for display side-by-side,
                     dividing up the total row width of 12 via 'size' setting
                     on each column. -->
                <!-- Display inline text element with objective value -->
                <vdl-column size="4">
                    <vdl-container><span vdl-text="Total cost: £"></span><span vdl-text="=insight.Formatter.formatNumber(scenario.entities.MincostSol.value, 
                <vdl-column size="8">
                    <vdl-container><span vdl-text="Date: "></span><span inline="true" vdl-text="=scenario.entities.RunDate.value" vd-selection="510.3619866979374"></span></vdl-container>
                <vdl-column size="6">
                        <!-- Display the 'flow' solution values, showing the 
                             table in rectangular format (last index across the 
                             columns) with an additional colum for the 
                             single-index array 'pltotal' printed in bold font. -->
                        <vdl-column size="12" heading="Customized Autotable">
                                <vdl-table-column entity="flow" heading="=r.label" vdl-repeat="=r in scenario.entities.REGION">
                                    <vdl-index-filter set="REGION" value="=r.value"></vdl-index-filter>
                                <vdl-table-column entity="pltotal" label="Total" class="Strong"></vdl-table-column>
                        <!-- Display 'flow' solution values using the default 
                             table format, enabling pagewise display with 
                             10 entries per per -->
                        <vdl-column size="12" heading="Default Autotable format">
                            <vdl-table page-mode="paged" page-size="10">
                                <vdl-table-column entity="flow"></vdl-table-column>
                <!-- Display 'flow' solution values as a stacked bar chart -->
                <vdl-column size="6" heading="Chart of result data">
                    <vdl-chart bar-mode="stack">
                        <vdl-chart-series entity="flow" series-set="PLANT"></vdl-chart-series>
                <vdl-column size="12">
                    <vdl-container><span vdl-text="Example of an SVG graphic generated by the Mosel model during a scenario run and added into scenario attachments:"></span></vdl-container>
                    <vdl-container><img vdl-attr="={src: scenario.attachments('transport.svg').dataUrl + '?lastModified='+scenario.attachments('transport.svg').lastModifiedDate}" width="400" height="400"  /></vdl-container>

Back to examples browserPrevious exampleNext example