Advanced GAMS 1. Good Modeling Practices 2. Fixing Misbehaving Models 3. Linking GAMS 4. Advanced GAMS Syntax.

Slides:



Advertisements
Similar presentations
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Advertisements

Lab 2 Data Evaluation & Validation Excel Scenarios & Functions Simon Chapter 2 & 3 URBPL 5/6010: Urban Research University of Utah Pam Perlich – BUC 103.
Chapter 5: Linear Programming: The Simplex Method
Solving LP Models Improving Search Special Form of Improving Search
What is GAMS?. While they are not NLP solvers, per se, attention should be given to modeling languages like: GAMS- AIMMS-
1 1 Slide © 2008 Thomson South-Western. All Rights Reserved © 2011 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or.
SOLVING LINEAR PROGRAMS USING EXCEL Dr. Ron Lembke.
GAMS advanced syntax From McCarl Guide From own guess-based experiments.
© 2007 Pearson Education Chapter 14: Solving and Analyzing Optimization Models.
Lecture 7: Linear Programming in Excel AGEC 352 Spring 2011 – February 9, 2011 R. Keeney.
Good modeling practices AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab.
GAMSCHK and GAMS Documentation AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved upon by many previous.
GAMS/GAMSIDE AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl and improved upon by previous lab instructors.
Examining a model for Flaws AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous.
ISM 206 Lecture 4 Duality and Sensitivity Analysis.
Computational Methods for Management and Economics Carla Gomes Module 4 Displaying and Solving LP Models on a Spreadsheet.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Spreadsheet Modeling & Decision Analysis:
Chapter 3 Planning Your Solution
1 1 Slide © 2009 South-Western, a part of Cengage Learning Slides by John Loucks St. Edward’s University.
1 1 Slides by John Loucks St. Edward’s University Modifications by A. Asef-Vaziri.
Introduction to Optimization
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Introduction to Mathematical Programming OR/MA 504 Chapter 3.
START EXCEL BUILD OR RETRIEVE YOUR OPTIMIZATION MODEL SAVE YOUR WORKBOOK!! CHOOSE “Solver…” IN THE “Tools” MENU SPECIFY IN SOLVER DIALOG BOX: 1.CELL TO.
Chapter 19 Linear Programming McGraw-Hill/Irwin
Solving Systems of Equations
Chapter 3 Linear Programming Methods 高等作業研究 高等作業研究 ( 一 ) Chapter 3 Linear Programming Methods (II)
Introduction to GAMS: Good modeling practices Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
Special Conditions in LP Models (sambungan BAB 1)
Multi-Dimensional Arrays
Linear Programming Topics General optimization model LP model and assumptions Manufacturing example Characteristics of solutions Sensitivity analysis Excel.
Programming Lifecycle
We can make Product1 and Product2. There are 3 resources; Resource1, Resource2, Resource3. Product1 needs one hour of Resource1, nothing of Resource2,
1 1 Slide © 2000 South-Western College Publishing/ITP Slides Prepared by JOHN LOUCKS.
Kerimcan OzcanMNGT 379 Operations Research1 Linear Programming: The Simplex Method Chapter 5.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
Chapter 7 Introduction to Linear Programming
Wiley Supplement B Linear Programming Operations Management by R. Dan Reid & Nada R. Sanders 4th Edition © Wiley 2010.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 6 Recursion.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
1 1 Slide © 2005 Thomson/South-Western Linear Programming: The Simplex Method n An Overview of the Simplex Method n Standard Form n Tableau Form n Setting.
Chapter 4 Linear Programming: The Simplex Method
Solve the following system using the elimination method.
Spreadsheet Modeling & Decision Analysis A Practical Introduction to Management Science 5 th edition Cliff T. Ragsdale.
Linear Program MAX C B X B + C NB X NB s.t. BX B + A NB X NB = b X B, X NB ≥ 0.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Linear Programming McGraw-Hill/Irwin Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
SENSITIVITY ANALYSIS. 2 Sensitivity Analysis Sensitivity analysis is carried out after optimal solution is found. Hence called as post optimality analysis.
LINGO TUTORIAL.
Linear Programming Topics General optimization model
Algorithm & Programming
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall
Chapter 7 Part 1 Edited by JJ Shepherd
6.5 Stochastic Prog. and Benders’ decomposition
Linear Programming Topics General optimization model
Chapter 4 Linear Programming: The Simplex Method
Linear Programming Topics General optimization model
Lecture 8 Exam model flaws
Linear Programming Topics General optimization model
Lecture 10 Comparative analysis
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
6.5 Stochastic Prog. and Benders’ decomposition
Presentation transcript:

Advanced GAMS 1. Good Modeling Practices 2. Fixing Misbehaving Models 3. Linking GAMS 4. Advanced GAMS Syntax

1 Good Modeling Practices  Document  Descriptive Names  Sensible Structure  Efficient Programming

Documentation  Use “*” comments  Symbol descriptions & units at declaration  $ontext $offtext  $oneolcom, $eolcom, $oninlinecom, …  Put all data in named parameters  Keep original data files  Track gams program versions

Naming  Choose Descriptive Names up to 64 Characters  Avoid Special Characters  Avoid set elements which look like numbers  Use …_var, …_equ, …_data  Use desired capitalization on 1st occurrence, be aware of unique element ordering  Name files which need to be run sequentially 1_..., 2_..., 3_...

Structure  Number and size of files  Number and organization of directories  Arrangement of sets, data, model, and base report  Scenarios, Scenario Report

Efficient GAMS usage  Use indexes, keep order index consistent  Automate data processing (gdx, awk, put)  Experiment with small models

Efficient GAMS usage  Taylor output  Check aggregate solutions first  Check speed and memory  Avoid irrelevant computations - use conditions

Efficiency and Errors  Avoid copies of the same piece of code to facilitate model development and to reduce errors from incomplete updating –use indexes –may introduce accounting variables to reduce code copies in report statements

2 Fixing Misbehaving Models  Unboundedness  Infeasibility  Bad solution  Scaling, Memory, Speed Problems

Using GAMSCHK  Option LP=GAMSCHK;  Option MIP=GAMSCHK;  Option NLP=GAMSCHK; Place option before solve statement Works best for large LP models where variables and equations have many indexes

GAMSCHK  Use on single solve statements (not in a scenario loop)  Start with small model versions  For larger models consider variable and equation selections

Tayloring GAMSCHK  Create.gck, where filename is the name of the file that is executed  Create gamschk.opt and use.optfile = 1;  Create/modify.opt

Content of.gck  Major keywords: –Analysis –Postopt –Displaycr –Blockpic  Variable/Equation selection possible under each keyword  … see solver manual or McCarl user guide for more exampels

Unboundedness  Place artificial bound on objective or other variables  Use GAMSCHK nonopt  Set filter in gamschk.opt

Infeasibility  Need artificial variables  Use BLOCKPIC to find candidate equations for artificial variables  GAMSCHK analysis  GAMSCHK postopt on non-zero artificial variables

Equation Candidates for Artificial Variables using Blockpic Output | V V V V | R | a a a a | H | | S Equ_1 | | E 0 Equ_2 | + | L - Equ_3 | - m m | L 0 Equ_4 | + | G Typ | u Assume that all variables are zero and then check which equations would be violated (infeasible). Thus, look for “L –”, “G +”, “E -“, or “E +”

Artificial Variables, 1  Declare artificial variables as nonnegative variables  Place a high penalty for artificial variables in the objective function –High negative values in max problems –High positive values in min problems  Use each artificial variable only in one constraint

Artificial Variables, 2  For each =L= equation with a negative r.h.s. value add the artificial variable to the l.h.s with a coefficient of -1.  For each =G= equation with a positive r.h.s. value add the artificial variable to the l.h.s with a coefficient of 1.  For each =E= equation with a non-zero r.h.s. value add two artificial variables to the l.h.s one with a coefficient of 1 and one with a coefficient of -1.

Bad solution  GAMSCHK analysis routine  GAMSCHK postopt routine  Trace from symptom to cause(s)

Tracing unrealistic solutions  No need to guess or remember all changes from the last working model  Decompose solution  Get rid of generic errors using GAMSCHK ANALYSIS routine

Tracing unrealistic solutions  Alternate between variables and equations in GAMSCHK  Alternate between individual GAMSCHK output and aggregated model structure  Use display statements (don‘t look at original data)

Fixing Analysis Errors  First decide between 2 general cases  A) Variable/Equation is present but shouldn‘t be present  B) Variable/Equation is not present but should be present

Case A) Variable/Equation is present but shouldn‘t be present Solution (99%):  Impose conditions

Case B) Variable/Equation is not present but should be present Solution:  Check conditions and data  Display data right before solve statement

Postopt Output  Output for Variables –Aij coefficients –Ui shadow prices –Aij * Ui –True reduced costs  Output for Equations –Aij coefficients –Xj variable levels –Aij*Xj –Shadow price

Conditions  Rule of thumb: Every variable block should have the same conditions in each equation block