gams a powerful
play

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


  1. GAMS: A POWERFUL OPTIMIZATION TOOL AND ITS INTERFACE TO MATLAB Muhammad Ismail

  2. Outline 2 Introduction GAMS Input File GAMS Output MATLAB Interface

  3. Introduction 3 - GAMS = General Algebraic Modeling System - Model linear, nonlinear, and mixed integer optimization 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]

  4. GAMS Structure and MATLAB Interface 4 MATLAB GAMS GAMS Input File GAMS Output File Compilation (name.gms) (name.lst) Optimization Solver

  5. Outline 5 Introduction GAMS Input File GAMS Output MATLAB Interface

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

  7. Problem Example 7 - 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

  8. Mathematical Formulation 8 Assignment variable Bandwidth allocation variable Binary Positive Max {log 1 + 𝑦 π‘œπ‘› 𝑐 π‘œπ‘› βˆ’ π‘ž π‘œπ‘› 𝑦 π‘œπ‘› 𝑐 π‘œπ‘› } π‘œ 𝑛 S.t. 𝐢 π‘›π‘—π‘œ,𝑛 ≀ 𝑦 π‘œπ‘› 𝑐 π‘œπ‘› ≀ 𝐢 𝑛𝑏𝑦,𝑛 βˆ€π‘› π‘œ Priority parameter 𝑦 π‘œπ‘› 𝑐 π‘œπ‘› ≀ 𝐷 π‘œ βˆ€π‘œ Matrix  Table π‘œ 𝑦 π‘œπ‘› = 1, 𝑦 π‘œπ‘› = 0,1 , βˆ€π‘› ∈ 𝑁 1 Total max. and π‘œ min. required Capacity of each network 𝑦 π‘œπ‘› = 1, βˆ€π‘› ∈ 𝑁 2 BW Vector Vector Problem  MINLP

  9. GAMS Input File 9 𝑂, 𝑁 Sets π‘ž π‘œπ‘›  Table, 𝑔  Scalar Data 𝐷 π‘œ , 𝐢 𝑛𝑏𝑦,𝑛 , 𝐢 π‘›π‘—π‘œ,𝑛  parameters 𝑦 π‘œπ‘›  Binary Variables 𝑐 π‘œπ‘›  Positive 𝑨  free Equations Objective function and constraints (equalities and inequalities) Model & Call Solver MINLP , solver = BARON

  10. GAMS Input File Cont. 10 1. Sets: Sets names Set declaration Sets members End Set declaration Comments 2. Data: Table name  Domains = rows and columns Table declaration Columns = same as M Rows = same as N Data End Table

  11. GAMS Input File Cont. 11 2. Data Cont.: Parameters Declaration Scalar Scalar Name Declaration Scalar Value End Parameters Names Data 3. Variables: Declare Obj. fn. Value Variables BW & Assign. And Domain End Variables types Parameters z = free by default Declaration

  12. GAMS Input File Cont. 12 4. Equations: Declare Equations Equations Names and End Equations Domain = ≀ Condition: β‰₯ Apply this only for M = 1:3, i.e. only for multi- homing users

  13. GAMS Input File Cont. 13 4. Model & Call Solver: Problem Type Solver Name Problem Modeling Maximize obj. fn.

  14. GAMS Input File Cont. 14 Problem type & Solver Sets Equations Data Model & Solve Variables

  15. Outline 15 Introduction GAMS Input File GAMS Output MATLAB Interface

  16. GAMS Outputs 16 Run your Model Name of my GAMS input file

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

  18. GAMS Outputs Cont. 18 Double click on error gives you its location in your code

  19. Outline 19 Introduction GAMS Input File GAMS Output MATLAB Interface

  20. MATLAB Interface 20 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

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

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

  23. MATLAB Interface Cont. 23 Step 3: Modify your GAMS Input File: No members 1. Open a file tstdat.gdx: β€œ gdxin No Values filename”  tstdat created by MATLAB 2. Load set members and parameters values from this file Comes from MATLAB 3. Close the file: β€œ gdxin ” Put the variables you want to read ; on MATLAB in file tstsol.gdx

  24. MATLAB Interface Cont. 24 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

  25. MATLAB Interface Cont. 25 C. Define Parameters Vector Scalar Table

  26. MATLAB Interface Cont. 26 D. Write Values in tstdat.gdx Write function E. Run the GAMS Input File Avoid crash Function: Run Name of my with loops GAMS input file GAMS input file

  27. MATLAB Interface Cont. 27 F. Read GAMS Results on MATLAB My GAMS Variables Read function

  28. MATLAB Interface Cont. 28 Define sets Define Parameters Write set members and Run GAMS input file parameters values Read GAMS results

  29. MATLAB Interface Cont. 29 G. Save GAMS Input File and MATLAB function on Same Directory H. On MATLAB Command Window Input Data Run GAMS and Read Results Results

  30. MATLAB Interface Cont. 30 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

  31. Summary 31 Introduction GAMS Input File GAMS Output MATLAB Interface

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend