Home »  Products »  Modelling Tools »  AMPL Studio »  Examples
Bookmark and Share     

Our Customers

  • HBOS Plc/ INSIGHT (UK)
  • UBS Investment Research (UK)
  • Fidelity Investment Ltd. (UK)
  • Deutsche Bank (UK)
  • APT INC (USA)
  • MOD (UK)
  • UNILEVER (UK/Netherlands)
  • US Coast Guard (USA)
  • British Gas (UK)
  • Southern Electric (UK)
  • DTI (UK)
  • Allocare (Switzerland)
  • NATO (Belgium)
  • Singapore Defence (Singapore)
  • Indian Institute of Management, Calcutta (India)

Contact Us

+91 9094532918 (M)

+91 44 4501 8472(O)

sales@optiriskindia.com

Quick contact form

 

AMPL Studio Example of Use

A Simple Real World Problem

National Insurance Associates carries an investment portfolio of stocks, bonds and other investment alternatives. Currently £200,000 of funds is available and must be considered for new investment opportunities. The four stock options National is considering and the relevant financial data are as follows:

  Stock
  A B C D
Price per share £100 £50 £80 £40
Annual rate of return 0.12 0.08 0.06 0.10
Risk measure per £ invested 0.10 0.07 0.05 0.08

Table: Financial Data

The risk measure indicates the relative uncertainty associated with the stock in terms of it realising the projected annual return: higher values indicate greater risk.

National’s top management has stipulated the following investment guidelines

  1. The annual rate of return for the portfolio must be 9%
  2. No one stock can account for more than 50% of the total sterling investment

They request you to find the investment decisions.

Minimize

Risk = 10*StockA + 3.5*StockB + 4*StockC + 4*StockD

Variables

StockA  ≤ 1000

StockB  ≤ 2000

StockC  ≤ 1250

StockD  ≤ 2500

Subject to

100*StockA + 50*StockB + 80*StockC + 40*StockD  ≤ 200000

12*StockA + 4*StockB + 4.8*StockC + 4*StockD ≤ 18000

Using AMPL Studio to Solve the Problem

Now the AMPL model is ready for the problem. Now you open the AMPL studio.

Create Workspace

In order to create a new workspace for NIA’s problem create a new workspace with the following steps.

Step 1: Choose New Workspace from the File menu.

File

AMPL example image

Step 2: Write workspace name as NIA and choose your appropriate folder (C:\) by clicking the ellipsis (…) button where you want to create your workspace.

AMPL example image

Click OK to create the workspace at your chosen folder.

AMPL example image

Create a Project

Step 1: Having created a workspace, we now define a new project by selecting Insert New Project from the Project menu.

AMPL example image

Step 2: Enter the Project name as "StepByStep1" and choose your preferred folder by clicking the ellipsis (…) button.

Check the Add templates checkbox and write the Model name as "StepByStep1.mod" and the Data instance as "StepByStep1.dat".

AMPL example image

Clicking OK will create a new project with the model and data template files within the created workspace.

Create an AMPL Model file

AMPL example image

Double clicking on the model file will open the model template file. The lines with # at the beginning are comment lines. The AMPL key words will be in blue and the numbers in red.

Step 1: Now write your AMPL model in this window.

Step 2: To check the syntax of your model choose Build Model menu from Build menu.

Build

AMPL example image

If any syntax errors occurred then the appropriate error messages will be displayed in the Console Window. In the above model displays the following syntax error.

Step 3: Double click on the error line(line 30) will display the following screen.

AMPL example image

Step 4: The line has two errors:

  1. Risk = should be replaced by Risk :
  2. Semicolon is missing at the end of line.

AMPL example image

Step 5: Make these corrections and compiling it again will show the following.

AMPL example image

Solve and Display Results

Step 1: In order to solve the model you need to select the solver. By default you will receive FortMP solver with your AMPL studio distribution. FortMP is a powerful solver and capable to handle this simple problem.

 

Solver

AMPL example image

Step 2: Now you can run this problem by choosing the Solve Problem menu from the Build Menu.

AMPL example image

Immediately the problem will be solved and the results will be displayed in the Editing Area.

AMPL example image