AMPL Recitation: Optimization - Banner Chemical Connor Makowski

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

AMPL Recitation

Optimization Banner Chemical


Connor Makowski

ctl.mit.edu

Before Starting This Recitation


You should:

Have AMPL installed on your computer


Or use the online access portal (we do not cover this)

Be able to run AMPL on your machine


Have watched the Banner Chemical example at
the beginning of this recitation

Recitation Agenda
AMPL Optimization

Nomenclature
Optimization in AMPL Algebraic
Optimization in AMPL Summation Notation

AMPL Optimization Basics


Every line ends with a semi colon;
Variables are preceded by var

Example: var x, y;

Constraints are preceded by subject to ... :

Example: Subject to capacity: x+y<2;

AMPL Algebraic Optimization Syntax


List Variables
Specify maximize/minimize and objective
function
Constrain the optimization
Solve
Display variables of interest

Optimization Banner Chemicals


var X_h >=0;
var X_s >=0;
maximize Total_Profit: 80*X_h+200*X_s;
subject to week_Cap: X_h+X_s<=110;
subject to cap_A: 3*X_h+2*X_s<=300;
subject to cap_B: X_h+3*X_s<=280;
solve;
display X_h, X_s, Total_Profit;

AMPL Summation Optimization Syntax


Set up Model

Set up notation
Add parameters
Specify variables
State objective function
Add constraints
Solve
Display variables of interest

AMPL Summation Optimization Syntax


set PRODUCTS = {"High","Supreme"};
set ADDITIVE = {"A","B"};
param raw_req {PRODUCTS,ADDITIVE} >=0;
param profit {PRODUCTS} >=0;
param availibility {ADDITIVE} >= 0;
param capacity=110;

High

Supreme Available

Additive A

3 gal

2 gal

300 gal

Additive B

1 gal

3 gal

280 gal

var X {PRODUCTS} >= 0;


#objective
maximize Total_Profit: sum {p in PRODUCTS} profit[p]*X[p];
subject to week_Cap: sum {p in PRODUCTS} X[p]<=capacity;
subject to additive_Cap {j in ADDITIVE}: sum {p in PRODUCTS} raw_req[p,j]*X[p]<=availibility[j];
#solve;
#display X, Total_Profit;
8

AMPL Summation Optimization Syntax


Set up Data

Specify data
Follow data structure of your model

Use the correct syntax


Param (name if matrix): Name of vector(s):=
Row titles and data of each vector

Optimization Banner Chemicals


param raw_req:

"A"
"High"
3
"Supreme" 2

"B" :=
1
3 ;

param: profit:=
"High" 80
"Supreme" 200 ;
param: availibility:=
"A"
300
"B"
280 ;

10

Questions, Comments, Suggestions?


Use the Discussion!

Margaret - After immersing herself in constrained


optimization
conmak@mit.edu

ctl.mit.edu

You might also like