Lecture 2 General Problem

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

Function Input and Output Lesson The Magic Box Consider a box that receives numbers in the top And alters them somehow and sends a (usually) different.
ITEC113 Algorithms and Programming Techniques
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.
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.
Chapter 2 Basic Elements of Fortan
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
STROUD Worked examples and exercises are in the text The logarithm segment of …
A GAMS TUTORIAL. WHAT IS GAMS ? General Algebraic Modeling System Modeling linear, nonlinear and mixed integer optimization problems Useful with large,
Introduction to GAMS: Good modeling practices Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
GAMS Anwendung Nutzeroberfläche eigene Programme Modellierungs- System GAMS AMPL ILOG Studio … Solver CPLEX, CONOPT, MINOS, COIN, BARON,...
4.4 Equations as Relations
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
Copyright © Cengage Learning. All rights reserved. 1 Functions and Their Graphs.
Introduction to GAMS: Formulation of a general problem Prof. Boyan Bonev Ivanov, Ph.D. Institute of Chemical Engineering-BAS.
Algebra 1 Section 3.7 Solve a formula for one of its variables. The formula for the area of a rectangle is A = L ∙W Solve the area formula for L and complete.
An Inverse Function.
Functions and relations
Chapter 9: Value-Returning Functions
User-Written Functions
MATLAB – More Script Files
Lecture 5 Good modeling Chengcheng Fei 2017 Fall
Algebraic Expressions
Lecture 4 Review: Circuit analysis examples
Lecture 7 GAMS Check Chengcheng Fei 2017 Fall
Lecture 4 Power of GAMS Chengcheng Fei 2017 Fall
1-5 Equations Goals: Solve equations with one variable
Introduction to MATLAB for Engineers, Third Edition
Lecture 9 Report writing
Linear Differential Equations
Algebra Bell-work 9/13/17 Turn in your HW! 1.) 7x – 6 = 2x + 9
Systems of Equations Lesson 41: Solve by using a matrix
JavaScript: Functions.
MATLAB: Structures and File I/O
Functions and relations
Simple linear equation
Number and String Operations
Programming Funamental slides
Lecture 8 Exam model flaws
Lecture 6 Conditionals, Subsets and Tuples in GAMS
Control Structure Senior Lecturer
Function Input and Output
Exponential and Logarithmic Equations and Models
Lesson 2: Input and Variables
Programming Funamental slides
Lists in Python Outputting lists.
Dr. Fowler  CCM Functions.
Linear Algebra Lecture 3.
Creating Noninput Items
COMPASS Practice Test D
Functions.
How would you use your calculator to solve 52?
Lecture 10 Comparative analysis
Linear Programming Excel Solver.
EECE.2160 ECE Application Programming
Two step equation Brackets
More JavaScript B. Ramamurthy 5/7/2019.
Linear Functions The output of function “f” when x is used as the input Independent Variable Slope: the difference in “f” for consecutive values of x y-intercept:
EECE.2160 ECE Application Programming
Solution Sets for Equations and Inequalities
Writing Linear Equations
Linear Algebra and Matrices
Which sequence is linear? How do you know?
Trigonometric Equations
Lesson 3.3 Writing functions.
Presentation transcript:

Lecture 2 General Problem Chengcheng Fei 2018 Fall Based on material written by Gillig and McCarl; Improved upon by many previous lab instructors; Special thanks to Zidong Mark Wang.

Review the simple model 1. Variable specifications 2. Equation specification Declaration Algebraic structure specification 3. Model statement 4. Solve statement

Simple to general models i=1: corn j=1: land i=2: wheat j=2: labor i=3: cotton

What is the difference 𝑖 and 𝑗 -- the subscripts in the algebraic models 𝑋 𝑖 -- variables with subscripts 𝑖 𝑐 𝑖 , 𝑏 𝑗 and 𝑎 𝑖𝑗 -- parameters with one subscripts (list) or two subscripts (table).

New Steps SET definitions Data Entry Variable Specification corresponds to the 𝑖 and 𝑗 SET definitions Data Entry Variable Specification Equation Specification a) Declaration b) Algebraic structure 5. Model Statement 6. Solve Statement corresponds to 𝑐 𝑖 , 𝑏 𝑗 and 𝑎 𝑖𝑗 different due to the previous two steps and the indices introduced

1. Set definitions Basic format Algebra: subscripts  GAMS: sets SET ItemName / element1 element2 / ; Example optional explanatory text Opening and ending slashes optional set associated text optional set associated text

1. Set definitions SET ItemName optional explanatory text Basic format SET ItemName optional explanatory text /element1 optional text, element2, element3/; Example

2. Data entry Parameters Tables Scalar Direct assignment

2.1 Parameter Basic format PARAMETER ItemName(SetDependency) Example / element1 associated value element2 associated value /; Example optional explanatory text

2.2 Table Basic format Example TABLE ItemName(set1, set2) set2elem1 set2elem2 set1elem1 value11 value21 set1elem2 value21 value22 ; Example optional explanatory text

2.3 Scalar Sometimes we need parameter which is set-independent Basic format SCALAR ItemName /value/; Example optional explanatory text

2.4 Direct assignment Example Basic format PARAMETER ItemName(set1, set2) ; ItemName(set1, set2) = expression; Example optional explanatory text

Sum Algebraic formula GAMS formula 𝑖 𝑤 𝑖𝑗 𝑖 𝑗 𝑤 𝑖𝑗 w(i,j) m n a 3 b 2

Basic calculation rules Example Find the answer for the following equations: 𝑥(𝑖)+𝑦(𝑖) 𝑥(𝑖)+𝑧 𝑥(𝑖)+𝑤(𝑖,𝑗) 𝑥(𝑖)∗𝑧 𝑥(𝑖)∗𝑦(𝑖) 𝑥(𝑖)∗𝑤(𝑖,𝑗) 𝑖 𝑤 𝑖𝑗 𝑖 𝑗 𝑤 𝑖𝑗 scalar z 5 i a b Para meter x(i) 1 2 y(i) 4 table w(i,j) m n 3

3. Variable declarations Basic format VARIABLE VarName1(set-dependency) VarName2(set-dependency) ; Example optional explanatory text optional explanatory text

4. Equation Declarations Basic format EQUATION EquName1(set-dependency) EquName2(set-dependency) ; Example optional explanatory text optional explanatory text

4. Equation: Algebraic structure specification General Structure: EquationName(Set-Dependency).. LHS (=e=, =l=, =g= ) RHS ; Equation Relation Type Example

Read the output Previous model statistics: New model statistics:

Solution Reports Shadow price: marginal values of resources. Reduced costs: marginal cost if a non-basic variable is forced to enter the solutions.

Display the output There are several ways to display your model output except the default outputs in the .lst file. I will talk about the display statement here and introduce more later if we have time. General format It can be used for: Quoted strings with single or double quotes Parameter, table or set names without any referencing to set-dependency Variable, equation or model attributes with the item name and attribute desired specified Display Item1, Item2, Item3 ;

Display the output Example

Display the output