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

Output formatting for a transportation model

Description
  • 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





transportres.vdl

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

        <!-- 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 -->
            <vdl-row>
                <!-- 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: &#163;"></span><span vdl-text="=insight.Formatter.formatNumber(scenario.entities.MincostSol.value, 
  '#,###.00')"></span></vdl-container>
                </vdl-column>
                <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>
            </vdl-row>
            <vdl-row>
                <vdl-column size="6">
                    <vdl-row>
                        <!-- 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>
                                <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>
                                <vdl-table-column entity="pltotal" label="Total" class="Strong"></vdl-table-column>
                            </vdl-table>
                        </vdl-column>
                    </vdl-row>
                    <vdl-row>
                        <!-- 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>
                            </vdl-table>
                        </vdl-column>
                    </vdl-row>
                </vdl-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-chart>
                </vdl-column>
            </vdl-row>
            <vdl-row>
                <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>
                </vdl-column>
            </vdl-row>
        </vdl-section>
    </vdl-page>
</vdl>

Back to examples browserPrevious exampleNext example