AMPL A Mathematical Programming Language 14 Dec21 Introduction

  • Slides: 14
Download presentation
AMPL: A Mathematical Programming Language 14 -Dec-21

AMPL: A Mathematical Programming Language 14 -Dec-21

Introduction n n Language for large-scale mathematical computing Generally used for large-scale optimization and

Introduction n n Language for large-scale mathematical computing Generally used for large-scale optimization and scheduling-type problems Syntax closely resembles the symbolic algebraic notation that is often used to describe mathematical programs Model linear programming, integer programming, and nonlinear programming, etc.

Language Features n Sets and indexing n n Simple sets Compound sets Computed sets

Language Features n Sets and indexing n n Simple sets Compound sets Computed sets Objectives and constraints n n n Linear Piecewise-linear Nonlinear Integer Network

Syntax n n n n n Constants: N Variables: i, j, p, x, y

Syntax n n n n n Constants: N Variables: i, j, p, x, y Keywords: param, var, let, in, minimize, subject to Operators: : =, *, etc. Expressions: i * j Statements: ; Comments: # Control: for Commands: solve, printf, display

Syntax Example n n File: Mult. mod Run using “model Mult. mod”

Syntax Example n n File: Mult. mod Run using “model Mult. mod”

AMPL Files n Each problem instance is coded in AMPL using three files: n

AMPL Files n Each problem instance is coded in AMPL using three files: n n n A model file (extension. mod): contains the mathematical formulation of the problem A data file (extension. dat): contains the numerical values of the problem parameters A run file (extension. run): specifies the solution algorithm (external and/or coded by the user in the AMPL language itself).

Linear Problem Example n Tons per hour (rate): n Profit per ton (profit): n

Linear Problem Example n Tons per hour (rate): n Profit per ton (profit): n Maximum tons (market): n Bands 200 Coils 140 Bands $25 Coils $30 Bands 6000 Coils 4000 If 40 hours of production time are available, how many tons of bands and how many tons of coils should be produced to bring in the greatest total profit?

Linear Problem Example: Cont. n n bands: the number of tons of bands to

Linear Problem Example: Cont. n n bands: the number of tons of bands to be produced coils: the number of tons of coils to be produced Maximize: $25 * X + $30 * Y Subject to: n n n 0 <= X <= 6000 0 <= Y <= 4000 (X / 200) + (Y / 140) <= 40 hours

Linear Problem Example: Data n File: steel. dat n n n Tons per hour

Linear Problem Example: Data n File: steel. dat n n n Tons per hour (rate): Profit per ton (profit): Maximum tons (market): Bands 200 Bands 25 Bands 6000 Coils 140 Coils 30 Coils 4000 bands: the number of tons of bands to be produced coils: the number of tons of coils to be produced

Linear Problem Example: Model n File: steel. mod

Linear Problem Example: Model n File: steel. mod

Linear Problem Example: Run n File: steel. run n Run by calling “include steel.

Linear Problem Example: Run n File: steel. run n Run by calling “include steel. run”

AMPL IDE n Download: http: //ampl. com/try-ampl/download-a-free-demo/

AMPL IDE n Download: http: //ampl. com/try-ampl/download-a-free-demo/

References: n AMPL Website: http: //ampl. com/ n AMPL Book: http: //ampl. com/resources/the-ampl-book/

References: n AMPL Website: http: //ampl. com/ n AMPL Book: http: //ampl. com/resources/the-ampl-book/

The End

The End