Lecture 5 Good modeling Chengcheng Fei 2017 Fall

Slides:



Advertisements
Similar presentations
Benchmark Series Microsoft Access 2010 Level 1
Advertisements

2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Macro Processor.
The Web Warrior Guide to Web Design Technologies
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.
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.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Introduction to GAMS: Good modeling practices Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
Spreadsheet-Based Decision Support Systems Chapter 22:
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Repetition Structures Repetition Structures allow you to write programs that will repeat program steps multiple times. –Also called Loops –Counter controlled.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
CSC350: Learning Management Systems COMSATS Institute of Information Technology (Virtual Campus)
Chapter 23: GUI Design Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Overview Excel is a spreadsheet, a grid made from columns and rows. It is a software program that can make number manipulation easy and somewhat painless.
Loops and Simple Functions CS303E: Elements of Computers and Programming.
Intermediate 2 Computing Unit 2 - Software Development.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
Learning Aim C.  In this section we will look at how text, tables, forms and frames can be used in web pages.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
JavaScript 101 Lesson 6: Introduction to Functions.
How To Make Easysite Forms By Joshua Crawley Contact:
World of Wokcraft The very best in Single pan cooking themed fantasy gaming!
Emdeon Office Batch Management Services This document provides detailed information on Batch Import Services and other Batch features.
Formulas, Functions, and other Useful Features
Introduction to Computing Science and Programming I
User-Written Functions
Chapter 7: Getting Input From Users
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Computer Fundamentals
Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall
Lecture 9 Report writing
Introduction To Flowcharting
Word Processing.
Web Programming– UFCFB Lecture 17
Intro to PHP & Variables
Assembler Design Options
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
For a new user you must click on the “Registration for Generator” link
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
Machine Independent Features
PROGRAMMING METHODOLOGY
Chapter 3 The DATA DIVISION.
Number and String Operations
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.
CS190/295 Programming in Python for Life Sciences: Lecture 6
An Introduction to Structured Program Design in COBOL
Benchmark Series Microsoft Word 2016 Level 2
Word offers a number of features to help you streamline the formatting of documents. In this chapter, you will learn how to use predesigned building blocks.
Do While (condition is true) … Loop
Chapter 1 Introduction(1.1)
Chapter 4 –Requirements for coding in Assembly Language
Faculty of Computer Science & Information System
Problem Solving Skill Area 305.1
3.1 Iteration Loops For … To … Next 18/01/2019.
Lecture 10 Comparative analysis
Programming Fundamentals (750113) Ch1. Problem Solving
Week 4 Lecture-2 Chapter 6 (Methods).
Programming Fundamentals (750113) Ch1. Problem Solving
Developing a Program.
Getting started – Example 1
Bent Thomsen Institut for Datalogi Aalborg Universitet
Variables in C Topics Naming Variables Declaring Variables
Lecture 2 General Problem
Presentation transcript:

Lecture 5 Good modeling 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.

Why bother ? How easy is it to reuse or modify a model at a later time for you? How easy can a colleague work with your code? A user-friendly model should include the following features Using longer names or descriptions Including comments on nature and source of data Including as much raw data as possible as opposed to externally calculated data Less * as a set speciation for input data Using sets to aid in readability A readable format

A Side note: Subset and universal set One can define subsets containing part of the elements of another set using a set statement.  The general format is    SET        subsetname(setname)  optional explanatory text                             /  Elementname1  optional explanatory text                                Elementname2 optional explanatory text/; where subsetname is the name of the subset and setname is the name of the “upper” set.

Example Allow items to be treated simultaneously in some places, but separately elsewhere.   Allow small to large modeling Conditional statements (discuss later)

Universal set * Set references may be indefinite allowing any entries at all by referring to the universal set.  One application of the universal set is quick report writing to make summary tables (will discuss in the following section).

Naming Conventions GAMS allows 63 character long names and 254 characters of explanatory text to define Sets , parameters, tables, scalars, variables, equations, models. The explanatory text must be contained on the same line as the identifier or label it describes. Names longer than 10 characters do not work well in multi-column displays It is wise to make GAMS code to be self documenting by using descriptive character names and make sure that there is no item that goes undefined Enter units, sources, and descriptions. Check for completeness with $ONSYMLIST (list the names of all symbols that have been defined and their explanatory text in alphabetical order grouped by symbol type). Check for unused items that are already defined with rf=list.ref in the dialogue box.

The Symbol Listing in the lst file after compliation. Gms file Lst file The Symbol Listing in the lst file after compliation. Default in GAMS is $OFFSYMLIST

The reference list

Using longer names Same algebras but different names

Including Comments Questions often asked when looking at a set of data are: Where did the data come from? What characteristics such as units, and year of applicability do those data possess? It is nice to go beyond the GAMS 254 character description by putting several lines of description comments identifying what document a data set is from including sources, page numbers, table number, years, units, etc.

Raw vs. Calculated Data Modelers often face two choices with respect to data. Enter raw data into GAMS and transform it to the extent needed inside GAMS Externally process data entering the final results in GAMS (e.g. from a spreadsheet where the data are previously manipulated) Recommendation: Put data in as close to the form as it was collected into GAMS and then manipulate the data in GAMS code Justification: (1) Over time spreadsheets change or get lost. (2) Keep a record of what you did.

Calculated Data Example Instead of directly entering the transportation cost that was previously calculated in the spreadsheet in GAMS using TABLE statement, one should enter a raw data in GAMS and then let GAMS do a calculation.

Cautions about Calculation Dynamic: calculations repeated every time the model is generated. Only calculations in the model .. statements are dynamic Static : calculations executed once only at the place the GAMS instruction appears in the code.

Repeated Static: calculations within a GAMS flow control structure (e Repeated Static: calculations within a GAMS flow control structure (e.g. loop) which are executed repeatedly but are static within the control structure.

Dynamic vs. Static Calculation The data on revenue is previously calculated using PARAMETER statement. Then this revenue is used in the OBJ.. equation

No * In input data Set Specification * in the first index position of MiscData. GAMS allows anything in that position suppressing “domain” checking. Suppose we mistyped endinv-value as endinv-valu, then GAMS code would compile and execute w/o a GAMS error but the result would be wrong.

No * In input data Set Specification Here if we replace * set with InputItem set, then GAMS would have given the error messages.

No * In input data Set Specification The solution from solving the model with mistyping on “endinv-value” as “endinv-valu” The solution from solving the model with correction on “endinv-value”

Improve Readability Format the code for readability using spacing and indents. Align item names, descriptions, and definitions Indent in sums, loops, and ifs to delineate terms Use blank lines to set things off Do not split variables between lines in equations, but rather keep them together with all their index positions

Do you prefer this?

… or this?

Questions?