GAMS: A POWERFUL OPTIMIZATION TOOL AND ITS INTERFACE TO MATLAB - - PowerPoint PPT Presentation

β–Ά
gams a powerful
SMART_READER_LITE
LIVE PREVIEW

GAMS: A POWERFUL OPTIMIZATION TOOL AND ITS INTERFACE TO MATLAB - - PowerPoint PPT Presentation

GAMS: A POWERFUL OPTIMIZATION TOOL AND ITS INTERFACE TO MATLAB Muhammad Ismail Outline 2 Introduction GAMS Input File GAMS Output MATLAB Interface Introduction 3 - GAMS = General Algebraic Modeling System - Model linear, nonlinear, and


slide-1
SLIDE 1

GAMS: A POWERFUL OPTIMIZATION TOOL AND ITS INTERFACE TO MATLAB

Muhammad Ismail

slide-2
SLIDE 2

Outline

Introduction GAMS Input File GAMS Output MATLAB Interface

2

slide-3
SLIDE 3

Introduction

  • GAMS = General Algebraic Modeling System
  • Model linear, nonlinear, and mixed integer
  • ptimization problems
  • GAMS can be downloaded from its home page:

http://www.gams.com/

  • Without a valid GAMS license, GAMS will operate as

a free demo with limitations on number of constraints and variables [GAMS license is placed, when available, in the GAMS directory]

3

slide-4
SLIDE 4

GAMS Structure and MATLAB Interface

GAMS Input File (name.gms) GAMS Output File (name.lst) GAMS Compilation Optimization Solver MATLAB

4

slide-5
SLIDE 5

Outline

Introduction GAMS Input File GAMS Output MATLAB Interface

5

slide-6
SLIDE 6

GAMS Input File Structure

Sets Data Variables Equations Model & Call Solver Correspond to indices in you problem Can be: parameters, tables, and scalar Can be: free (-∞,+∞), +ve, -ve, binary, integer Equalities and inequalities LP , NLP , MIP , MINLP

6

slide-7
SLIDE 7

Problem Example

  • Consider 𝑂 networks with overlapped coverage and 𝑁 users
  • Out of 𝑁 users, we have:

𝑁1 users can get service (bandwidth) using only single-network 𝑁2 users can get service (bandwidth) using all available networks, i.e. multi-homing

  • Obj.: Find network assignment for single-network users and

bandwidth allocation for both single-network and multi-homing users which maximizes some utility function

7

slide-8
SLIDE 8

Mathematical Formulation

Max {log 1 + π‘¦π‘œπ‘›π‘π‘œπ‘› βˆ’ π‘žπ‘œπ‘›π‘¦π‘œπ‘›π‘π‘œπ‘›}

𝑛 π‘œ

S.t. πΆπ‘›π‘—π‘œ,𝑛 ≀ π‘¦π‘œπ‘›π‘π‘œπ‘› ≀ 𝐢𝑛𝑏𝑦,𝑛

π‘œ

βˆ€π‘› π‘¦π‘œπ‘› = 1, π‘¦π‘œπ‘› = 0,1 , βˆ€π‘› ∈ 𝑁1

π‘œ

π‘¦π‘œπ‘› = 1, βˆ€π‘› ∈ 𝑁2 Assignment variable Binary Bandwidth allocation variable Positive Priority parameter Matrix  Table Total max. and

  • min. required

BW Vector Problem  MINLP π‘¦π‘œπ‘›π‘π‘œπ‘› ≀ π·π‘œ

π‘œ

βˆ€π‘œ Capacity of each network Vector

8

slide-9
SLIDE 9

GAMS Input File

Sets Data Variables Equations Model & Call Solver 𝑂, 𝑁 π‘žπ‘œπ‘›οƒ¨ Table, 𝑔 Scalar π·π‘œ, 𝐢𝑛𝑏𝑦,𝑛, πΆπ‘›π‘—π‘œ,𝑛  parameters π‘¦π‘œπ‘›  Binary π‘π‘œπ‘›  Positive Objective function and constraints (equalities and inequalities) MINLP , solver = BARON

9

𝑨  free

slide-10
SLIDE 10

GAMS Input File Cont.

Set declaration End Set declaration Sets names Comments Sets members

  • 1. Sets:
  • 2. Data:

Table declaration Table name  Domains = rows and columns Columns = same as M Rows = same as N Data End Table

10

slide-11
SLIDE 11

GAMS Input File Cont.

  • 2. Data Cont.:

Parameters Declaration Parameters Names And Domain Data End Parameters Declaration Scalar Declaration Scalar Name Scalar Value End

  • 3. Variables:

Declare Variables

  • Obj. fn. Value

BW & Assign. Variables types z = free by default

11

slide-12
SLIDE 12

GAMS Input File Cont.

  • 4. Equations:

Declare Equations End Equations Equations Names and Domain = ≀ β‰₯ Condition: Apply this only for M = 1:3, i.e.

  • nly for multi-

homing users

12

slide-13
SLIDE 13

GAMS Input File Cont.

  • 4. Model & Call Solver:

Problem Type Solver Name Problem Modeling Maximize obj. fn.

13

slide-14
SLIDE 14

GAMS Input File Cont.

Problem type & Solver Sets Data Variables Equations Model & Solve

14

slide-15
SLIDE 15

Outline

Introduction GAMS Input File GAMS Output MATLAB Interface

15

slide-16
SLIDE 16

GAMS Outputs

Run your Model Name of my GAMS input file

16

slide-17
SLIDE 17

GAMS Outputs Cont.

Listing file Check the results of your variables B is a Matrix 𝐢 = 0.101 … . 0.411 … . Rows = Networks Columns = Users Add bounds Necessary for BARON to guarantee global optimality

17

slide-18
SLIDE 18

GAMS Outputs Cont.

Double click on error gives you its location in your code

18

slide-19
SLIDE 19

Outline

Introduction GAMS Input File GAMS Output MATLAB Interface

19

slide-20
SLIDE 20

MATLAB Interface

Why?

  • Test how performance changes with some parameters, e.g.

how does bandwidth allocation changes with number of users?

  • If you have a simulation on MATLAB and part of your MATLAB

code needs to solve a complex optimization problem

  • Better view of your results  Matrix form, or a plot

GDX Utilities  GAMS Data Exchange

20

slide-21
SLIDE 21

MATLAB Interface Cont.

Step 1: Update MATLAB Path to Include GAMS Directory: MATLAB: File > Set path > Add folder Browse Add

21

slide-22
SLIDE 22

MATLAB Interface Cont.

Step 2: Update System Variables to Include GAMS Directory: Computer: Right click > Properties > Advanced system settings Environment Variables Edit and Type GAMS Path

22

slide-23
SLIDE 23

MATLAB Interface Cont.

Step 3: Modify your GAMS Input File:

No members No Values Comes from MATLAB

  • 1. Open a file tstdat.gdx: β€œgdxin

filename”  tstdat created by MATLAB

  • 2. Load set members and parameters

values from this file

  • 3. Close the file: β€œgdxin”

Put the variables you want to read

  • n MATLAB in file tstsol.gdx

;

23

slide-24
SLIDE 24

MATLAB Interface Cont.

Step 4: MATLAB File:

  • A. Create MATLAB function: inputs = set members and parameters

data, outputs: problem variables

  • B. Define Sets

Same as in my GAMS input file

24

slide-25
SLIDE 25

MATLAB Interface Cont.

  • C. Define Parameters

Vector Scalar Table

25

slide-26
SLIDE 26

MATLAB Interface Cont.

  • D. Write Values in tstdat.gdx

Write function

  • E. Run the GAMS Input File

Avoid crash with loops Function: Run GAMS input file Name of my GAMS input file

26

slide-27
SLIDE 27

MATLAB Interface Cont.

  • F. Read GAMS Results on MATLAB

My GAMS Variables Read function

27

slide-28
SLIDE 28

MATLAB Interface Cont.

Define sets Define Parameters Write set members and parameters values Run GAMS input file Read GAMS results

28

slide-29
SLIDE 29

MATLAB Interface Cont.

  • G. Save GAMS Input File and MATLAB function on Same Directory
  • H. On MATLAB Command Window

Input Data Run GAMS and Read Results Results

29

slide-30
SLIDE 30

MATLAB Interface Cont.

Also, I can make a for loop in MATLAB on one of the parameters and fix other parameters to study some performance and plot results on MATLAB

30

slide-31
SLIDE 31

Summary

Introduction GAMS Input File GAMS Output MATLAB Interface

31