Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall

Slides:



Advertisements
Similar presentations
What is GAMS?. While they are not NLP solvers, per se, attention should be given to modeling languages like: GAMS- AIMMS-
Advertisements

Advanced GAMS 1. Good Modeling Practices 2. Fixing Misbehaving Models 3. Linking GAMS 4. Advanced GAMS Syntax.
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.
Comparative Analysis Multiple Submissions vs. Loops AGEC 641 Lab, Fall 2010 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved.
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.
Formulation of a General Problem AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl; Improved upon by many previous.
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.
Power of GAMS AGEC 641 Lab, Fall 2011 Mario Andres Fernandez Based on material written by Gillig and McCarl. Improved upon by many previous lab instructors.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
131 Agenda Overview Review Roles Lists Libraries Columns.
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.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Introduction to GAMS: Good modeling practices Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
Lesson 1: Introduction to ABAP OBJECTS Todd A. Boyle, Ph.D. St. Francis Xavier University.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Lesson 10 - Mail Merge and Reviewing Documents Advanced Microsoft Word.
Introduction to MATLAB for Engineers Third Edition William J. Palm III Chapter 10 Simulink PowerPoint to accompany Copyright © The McGraw-Hill Companies,
GAMS: General Algebraic Modeling System Linear and Nonlinear Programming The full system documentation is provided electronically with the software.
JavaScript 101 Lesson 6: Introduction to Functions.
Lesson 4 Basic Text Formatting. Objectives ● I ● In this tutorial we will: ● Introduce Wiki Syntax ● Learn how to Bold and Italicise text, and add Headings.
N5 Databases Notes Information Systems Design & Development: Structures and links.
LINGO TUTORIAL.
Unit 2 Technology Systems
Journal of Mountain Science (JMS)
Microsoft Word Objectives: Word processing using Microsoft Word
EET 2259 Unit 13 Strings and File I/O
KARES Demonstration.
Copyright © 2016 Pearson Canada Inc.
User-Written Functions
Lecture 5 Good modeling Chengcheng Fei 2017 Fall
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Lecture 9 Report writing
Microsoft Excel A Spreadsheet Program.
Using the Excel Creation Template to Create a Variable Parameter Problem (Macro Enabled “Alpha 1.4.2”) Getting started – Example 1 Note – You should be.
Chapter 2: Getting Data into SAS
Intro to PHP & Variables
Defining Styles and Automatically Creating Table of Contents and Indexes Word Processing 4.03.
For a new user you must click on the “Registration for Generator” link
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Exploring Microsoft® Excel® 2016 Series Editor Mary Anne Poatsy
Chapter 7: Macros in SAS Macros provide for more flexible programming in SAS Macros make SAS more “object-oriented”, like R Not a strong suit of text ©
Functions BIS1523 – Lecture 17.
Number and String Operations
Use of Mathematics using Technology (Maltlab)
Lecture 8 Exam model flaws
Lecture 6 Conditionals, Subsets and Tuples in GAMS
Navya Thum February 13, 2013 Day 7: MICROSOFT EXCEL Navya Thum February 13, 2013.
Microsoft Office Access 2003
Benchmark Series Microsoft Word 2016 Level 2
Arrays
Variables and Expressions
Alio FAS Reports Made Easy
Tonga Institute of Higher Education
Access: Queries IV Participation Project
Access: Queries II Participation Project
Solving Linear Equations
Lecture 10 Comparative analysis
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
A QUICK START TO OPL IBM ILOG OPL V6.3 > Starting Kit >
Lesson 3 Chapter 10.
Functions continued.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Getting started – Example 1
EET 2259 Unit 13 Strings and File I/O
Simplex method (algebraic interpretation)
Lecture 2 General Problem
Presentation transcript:

Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall Based on material written by Gillig and McCarl; Improved upon by many previous lab instructors; Special thanks to Zidong Mark Wang.

R Example

R Result

Matlab Example

Matlab Result Result of “linprog” Function Result of “solve” Function

Why Do We Use GAMS? Algebraic Modeling Display Formatting Context Changes Expandability of Models Adding Conditionals Display Formatting Self Documenting Nature Small to Large Model Development Model Library Use by others Nonlinear and other problem forms

1.a Context Changes The same algebraic model can be used in multiple contexts often with the same or very similar structure. For example, we have two problems: A crop production problem where a farmer wants to maximize the net farm income from growing crops. a manufacturing production problem where a manufacturer wants to maximize the net income from making goods.

1.a Context Changes

1.b Expandability - Scope Instead of growing 3 crops, now a farmer also wants to grow soybeans. One needs only to add an element in set PROCESS table ResourceUse parameter revenues Other data and the model structure remains the SAME!

1.b Expandability -Augmenting Existing Models In the previous example of crop production, a new constraint is added such as at least 10 units of wheat to be produced for self-consumption. Modification includes: adding data on minimum land use, and equation specification on minimum land use.

1.c Adding Conditionals Modelers need to be able to write expressions that operate over less than full sets or incorporate various model features conditionally depending on data.   Land types (dry land or irrigated land ) for crop production Seasonal labor availability Such tasks can be accomplished in GAMS using conditionals. Several alternatives are available for conditional statements. We will talk about this in details later in Lab Lecture 6.

2. Control display format General Format option Itemname:Decimal:RowItems:ColumnItems Explanation Decimal: number of decimal places to be included RowItems: Number of indices displayed within rows ColumnItems: Number of indices displayed within columns Example ColumnItems cannot be 0!

3. Self-documenting Nature GAMS allows one to add explanatory text when naming SETS, PARAMETERS, TABLES, VARIABLES, EQUATIONS, but it is a good habit to name them with easy-understanding words instead of simple letters. (A) (B)

3. Self-documenting Nature Always remember commenting your code. Comments can not only help others read your code, but also help yourself read for future references. Comment a line: asterisk * Comment multiple lines: put comments between $ONTEXT and $OFFTEXT End of line comment: Use commands$oneolcom and $eolcom “two character specification” Default specification is !! In line comment: $oninline /*  */ and $inlinecom beginningcharacter endingcharacter

4. Small to large model GAMS expandability allows the same model structure, calculations, and report writing to be used with SETS with few elements vs. SETS with many items. Using a small data set allows up to examine the model structure and function easier and better. Then later one can use same algebra and full problem. To expand, one uses SmallStocks(Stocks) = YES;

Large Model Facilities

5. GAMS model library GAMS has been used as a standard in optimization models in many fields Models exist from experienced users that address similar problems Textbook (McCarl and Spreen) Fixing Models Book (McCarl) GAMS Library GAMS Newsletter

6. Save and Restart GAMS permits one to separate data from the algebraic model, particularly through the use of SAVE , RESTART, and $INCLUDE. This feature allows data files to be worked on by other people and also increases run efficiency. One also can use this to separate code functions (e.g. data section, model structure, and report writing).

6. Save and Restart Two files: data.gms and model.gms. Run data.gms Type the content “s=data” in the red box before you click “Run GAMS” When finished running data.gms which includes all of data, GAMS will save all the information as data.g00 where it is ready to be used.

6. Save and Restart Run model.gms Type the content “r=data s=model” in the red box before running the model When finished solving model.gms, GAMS will save all information including solutions in model.g00 where it is ready to be used later, say, report writing. You can also specify the path r=c:\foldername\data default path of GAMS is with the project file

7. Non-linear and Other Problem Forms Set declarations Parameter declarations Variable declarations Equation declarations Specifying algebraic structure Model specifications Solve specifications Data Model SOLVE Ex USING LP MAXIMIZING Z; SOLVE Ex USING MIP MAXIMIZING Z; SOLVE Ex USING NLP MAXIMIZING Z;

Questions?