Table Of ContentNew AMPL Interfaces for
Enhanced Optimization Model
Development and Deployment
Robert Fourer
AMPL Optimization Inc.
www.ampl.com — +1 773-336-AMPL
INFORMS Conference on
Business Analytics & Operations Research
Boston, 30 March – 1 April 2014
Track 11, Monday 1:50-2:40, Software Tutorials
Robert Fourer, New AMPL Interfaces for Development & Deployment 1
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Outline
Deploying models
Scripting
Internal modeling/programming language
AMPL API (Application Programming Interfaces)
External programming language support
General-purplse languages: C++, Java, .NET, Python
Analytics languages: MATLAB, R
Developing models
More natural formulations
Logical conditions
Quadratic constraints
AMPL IDE (Integrated Development Environment)
Unified editor & command processor
Built on the Eclipse platform
Robert Fourer, New AMPL Interfaces for Development & Deployment 3
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Introductory Example
Multicommodity transportation . . .
Products available at factories
Products needed at stores
Plan shipments at lowest cost
. . . with practical restrictions
Cost has fixed and variable parts
Shipments cannot be too small
Factories cannot serve too many stores
Robert Fourer, New AMPL Interfaces for Development & Deployment 4
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
Given
(cid:1841) Set of origins (factories)
(cid:1830) Set of destinations (stores)
(cid:1842) Set of products
and
(cid:1853) Amount available, for each (cid:1861) ∈ (cid:1841) and (cid:1868) ∈ (cid:1842)
(cid:3036)(cid:3043)
(cid:1854) Amount required, for each (cid:1862) ∈ (cid:1830) and (cid:1868) ∈ (cid:1842)
(cid:3037)(cid:3043)
(cid:1864) Limit on total shipments, for each (cid:1861) ∈ (cid:1841) and (cid:1862) ∈ (cid:1830)
(cid:1861)(cid:1862)
(cid:1855) Shipping cost per unit, for each (cid:1861) ∈ (cid:1841), (cid:1862) ∈ (cid:1830), (cid:1868) ∈ (cid:1842)
(cid:1861)(cid:1862)(cid:1868)
(cid:1856) Fixed cost for shipping any amount from (cid:1861) ∈ (cid:1841) to (cid:1862) ∈ (cid:1830)
(cid:1861)(cid:1862)
(cid:1871) Minimum total size of any shipment
(cid:1866) Maximum number of destinations served by any origin
Robert Fourer, New AMPL Interfaces for Development & Deployment 5
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
Mathematical Formulation
Determine
(cid:1850) Amount of each (cid:1868) ∈ (cid:1842) to be shipped from (cid:1861) ∈ (cid:1841) to (cid:1862) ∈ (cid:1830)
(cid:1861)(cid:1862)(cid:1868)
(cid:1851) 1 if any product is shipped from (cid:1861) ∈ (cid:1841) to (cid:1862) ∈ (cid:1830)
(cid:1861)(cid:1862)
0 otherwise
to minimize
∑ ∑ ∑ (cid:1855) (cid:1850) (cid:3397) ∑ ∑ (cid:1856) (cid:1851)
(cid:3036)∈(cid:3016) (cid:3037)∈(cid:3005) (cid:3043)∈(cid:3017) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3037)(cid:3043) (cid:3036)∈(cid:3016) (cid:3037)∈(cid:3005) (cid:3036)(cid:3037) (cid:3036)(cid:3037)
Total variable cost plus total fixed cost
Robert Fourer, New AMPL Interfaces for Development & Deployment 6
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
Mathematical Formulation
Subject to
∑ (cid:1850) (cid:3409) (cid:1853) for all (cid:1861) ∈ (cid:1841), (cid:1868) ∈ (cid:1842)
(cid:3037)∈(cid:3005) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3043)
Total shipments of product (cid:1868) out of origin (cid:1861)
must not exceed availability
∑ (cid:1850) (cid:3404) (cid:1854) for all (cid:1862) ∈ (cid:1830), (cid:1868) ∈ (cid:1842)
(cid:3036)∈(cid:3016) (cid:3036)(cid:3037)(cid:3043) (cid:3037)(cid:3043)
Total shipments of product (cid:1868) into destination (cid:1862)
must satisfy requirements
Robert Fourer, New AMPL Interfaces for Development & Deployment 7
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
Mathematical Formulation
Subject to
∑ (cid:1850) (cid:3409) (cid:1864) (cid:1851) for all (cid:1861) ∈ (cid:1841), (cid:1862) ∈ (cid:1830)
(cid:3043)∈(cid:3017) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3037) (cid:3036)(cid:3037)
When there are shipments from origin (cid:1861) to destination (cid:1862),
the total may not exceed the limit, and (cid:1851) must be 1
(cid:3036)(cid:3037)
∑ (cid:1850) (cid:3410) (cid:1871)(cid:1851) for all (cid:1861) ∈ (cid:1841), (cid:1862) ∈ (cid:1830)
(cid:3043)∈(cid:3017) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3037)
When there are shipments from origin (cid:1861) to destination (cid:1862),
the total amount of shipments must be at least (cid:1871)
∑ (cid:1851) (cid:3409) (cid:1866) for all (cid:1861) ∈ (cid:1841)
(cid:3037)∈(cid:3005) (cid:3036)(cid:3037)
Number of destinations served by origin (cid:1861)
must be as most (cid:1866)
Robert Fourer, New AMPL Interfaces for Development & Deployment 8
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
AMPL Formulation
Symbolic data
set ORIG; # origins
set DEST; # destinations
set PROD; # products
param supply {ORIG,PROD} >= 0; # availabilities at origins
param demand {DEST,PROD} >= 0; # requirements at destinations
param limit {ORIG,DEST} >= 0; # capacities of links
param vcost {ORIG,DEST,PROD} >= 0; # variable shipment cost
param fcost {ORIG,DEST} > 0; # fixed usage cost
param minload >= 0; # minimum shipment size
param maxserve integer > 0; # maximum destinations served
Robert Fourer, New AMPL Interfaces for Development & Deployment 9
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
AMPL Formulation
Symbolic model: variables and objective
var Trans {ORIG,DEST,PROD} >= 0; # actual units to be shipped
var Use {ORIG, DEST} binary; # 1 if link used, 0 otherwise
minimize Total_Cost:
sum {i in ORIG, j in DEST, p in PROD} vcost[i,j,p] * Trans[i,j,p]
+ sum {i in ORIG, j in DEST} fcost[i,j] * Use[i,j];
∑ ∑ ∑ (cid:1855) (cid:1850) (cid:3397) ∑ ∑ (cid:1856) (cid:1851)
(cid:3036)∈(cid:3016) (cid:3037)∈(cid:3005) (cid:3043)∈(cid:3017) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3037)(cid:3043) (cid:3036)∈(cid:3016) (cid:3037)∈(cid:3005) (cid:3036)(cid:3037) (cid:3036)(cid:3037)
Robert Fourer, New AMPL Interfaces for Development & Deployment 10
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Multicommodity Transportation
AMPL Formulation
Symbolic model: constraint
subject to Supply {i in ORIG, p in PROD}:
sum {j in DEST} Trans[i,j,p] <= supply[i,p];
∑ (cid:1850) (cid:3409) (cid:1853) , for all (cid:1861) ∈ (cid:1841), (cid:1868) ∈ (cid:1842)
(cid:3037)∈(cid:3005) (cid:3036)(cid:3037)(cid:3043) (cid:3036)(cid:3043)
Robert Fourer, New AMPL Interfaces for Development & Deployment 11
INFORMS Analytics Boston —30 March-1 April 2014 —Track 11 Software Tutorials
Description:Internal modeling/programming language. ❖ AMPL API (Application Programming Interfaces). * External programming language support. * General-purplse languages: C++, Java, .NET, Python. * Analytics languages: MATLAB, R. Developing models. ❖ More natural formulations. * Logical conditions.