GAMS advanced syntax From McCarl Guide From own guess-based experiments.

Slides:



Advertisements
Similar presentations
Utilizing the GDB debugger to analyze programs Background and application.
Advertisements

Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
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.
Guide To UNIX Using Linux Third Edition
Ch 111 Chapter 11 Advanced Batch Files. Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
1 CSC103: Introduction to Computer and Programming Lecture No 26.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
GAMS General Algebraic Modeling System Presentation No.2 Instructor: Dr. Abbas Seifi Prepares by: Masoud Barah Applied OR Modeling Course.
Introduction to GAMS: Good modeling practices Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
Spreadsheet-Based Decision Support Systems Chapter 22:
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
An Introduction to Unix Shell Scripting
Macros. There are three basic phases for C programming. preprocessing, compiling, and linking. C input file is first passed to a preprocessing program.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Matlab Programming for Engineers Dr. Nidal Farhat Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
How to get started with GAMS MS&E 348 – Lecture 1/20/04.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Chapter 13 Programming in the Large Dr. Jiung-yao Huang Dept. Comm. Eng. Nat. Chung Cheng Univ. TA: 鄭筱親 陳昱豪.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
End of unit assessment Challenge 1 & 2. Course summary So far in this course you have learnt about and used: Syntax Output to screen (PRINT) Variables.
JavaScript, Fourth Edition
Shell Scripting – Putting it All Together. Agenda Escaping Characters Wildcards Redirecting Output Chaining and Conditional Chaining Unnamed and Named.
S11-1 ADM , Section 11, August 2005 Copyright  2005 MSC.Software Corporation SECTION 11 MACROS: OVERVIEW.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
Linux+ Guide to Linux Certification, Second Edition
Introduction to Bash Shell. What is Shell? The shell is a command interpreter. It is the layer between the operating system kernel and the user.
Scion Macros How to make macros for Scion The Fast and Easy Guide.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Bioinformatics Introduction to Perl. Introduction What is Perl Basic concepts in Perl syntax: – variables, strings, – Use of strict (explicit variables)
Batch Files Flow of Control to Strengthen Copyright © by Curt Hill.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Batch Files More flow of control Copyright © by Curt Hill.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
CS422 Principles of Database Systems Stored Procedures and Triggers Chengyu Sun California State University, Los Angeles.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Lecture 3 Translation.
Week 3-4 Control flow (review) Function definition Program Structures
User-Written Functions
Lecture 5 Good modeling Chengcheng Fei 2017 Fall
Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall
Testing and Debugging.
Shell Programming (ch 10)
SECTION 3 MACROS: OVERVIEW.
Scripts & Functions Scripts and functions are contained in .m-files
Writing Shell Scripts ─ part 3
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
Chapter 5 - Functions Outline 5.1 Introduction
Topics Introduction to File Input and Output
C Preprocessor(CPP).
Topics Introduction to File Input and Output
Lecture 18 Compilers and Language Translation (S&G, ch. 9)
Presentation transcript:

GAMS advanced syntax From McCarl Guide From own guess-based experiments

System Attributes

Gams Attributes

System Attributes System.<attribute>  Parameter report1(*); Set report2(*);  report1("memory")=%system.memory%;  report2("%system.date%")=yes;  display report1,report2;

GAMS Attributes Command line arguments gams.<attribute>  Parameter report1(*); Set report2(*);  report1(“lpsolver")=%gams.lp%;  report2("%gams.lp%")=yes;  display report1,report2;

GAMS Timing Compilation Syntax check $control operations Execution Syntax execution

At Execution Time Execute normal GAMS syntax:  Data(Set)=normal(10,2);  Solve, If, Sum, Smin, Loop, …  Execute, Execute_unload  Option, Display, …

At Compilation Time  Check GAMS syntax  Execute special $ sign syntax  $call  $load  $unload

Save Restart  Break code into sequentially executed pieces  Avoids compile time problems (if code segment 1 produces a file to be used in code segment 2)  Can be nicely automated

$ Dollar Options  $ must be in first column  Several $ options can be in one line  $onlisting offsymlist  Some options require values, e.g.   Generally, carried out at compile time!

External file inclusion $include filename $libinclude filename $libinclude filename $batinlcude filename $batinlcude filename $sysinclude filename $sysinclude filename Can append path statements before filename (absolute, relative, %var%)

GDX $Control Variables $Gdxin filename.gdx $Load p1 s1 $Gdxin $Gdxout filename.gdx $Unload p1 s1  dangerous because $Gdxout of compile time For unload use better: Execute_Unload

Output (*.lst file) $Control  $onlisting  $offlisting  $onuellist  $offuellist  $onupper  $offupper  $show  $single  $double  $onsymlist  $offsymlist  $onsymxref  $offsymxref  $offdollar  $ondollar  $offinclude  $oninclude  …

Input file control  $offmargin  $onmargin  $mincol 20 maxcol 40  $ondelim  $offdelim  $ontext  $offtext  $offglobal  $onglobal

Messages / Comments  $log  $error  $error  $remark  $title  $stitle  $hidden  $oneolcom  $offeolcom  $oninline  $offinline  $offnestcom  $onnestcom

GAMS syntax symbol substitution  $comment  $comment  $stars  $dollar  $eolcom  $inlinecom Why change?

Forced program termination $exit… quits only local file $abort text… stops entire compilation $stop… stops without error $goto name… jumps to: $label name Usually these termination statements are combined with $if statements

Control Variables  $set name value  $setlocal name value  $setglobal name value  $drop name  $droplocal name  $dropglobal name Action scope differs: (setlocal < set < setglobal) (setlocal < set < setglobal)

Conditional Control Statements  $If condition statementtoexecute  $Ifi… case insensitive $if version  $ife…  $ifthen  $ifelse  $else

GAMS Symbol Tests $if exist filename statement $if dexist dirname statement $if declared symbol statement $if dimension 4 symbol statement $if defined symbol statement $if putopen statement $if settype symbol statement (partype, filtype, equtype, vartype, modtype, …) $if errorfree gamsstatement $if errorlevel n gamsstatement $if warnings gamsstatement Statement can be special or normal gams syntax

File Creation at Compile Time  $Onecho > file  $Offecho

$Macro  $macro ratio(a,b) a/b  $macro reciprocal(a) 1/a  Scalar a /2/,d/4/,c;  c=ratio(a,d); display c;  c=reciprocal(d);

Other features  ask  Allows user dialog

Undocumented $maxgoto$onuni