Академический Документы
Профессиональный Документы
Культура Документы
GAMS TUTORIAL
GAMS Basics
GAMS: General Algebraic Modeling System (GAMS) High-level modeling system for mathematical programming and optimization Useful only for solving optimization problems
Student version (with restrictions on number of variables and number of constraints) available at: http://www.gams.com/
2 BioE 494
GAMS Basics
GAMS advantages:
Problem representation is much simpler: Intuitive representation due to the representation syntax Various output options to analyze the results and carry out debugging Incorporates different solvers for the given problem and various options to select desired solver properties Possible to define an integer variable
GAMS disadvantages:
No option for data visualization No option to include breakpoints to debug the code Performs only optimization: Cannot carry out other related tasks such as ODE simulation.
3 BioE 494
GAMS Environment
4 BioE 494
5 BioE 494
Set Declaration
Very important aspect of a GAMS model Declaration necessary for multi-dimensional parameter/variable declaration Simple set example:
courses={BioE 123, BioE 234, BioE 345} set courses / BioE 123, BioE 234, BioE 345 / ;
Sequence set:
Year={2000, 2001, 2002, 2010} set Year /2000 * 2010/ ;
7 BioE 494
12 15 21 18 21
34 31 33 21 31
25 30 32 22 26;
9 BioE 494
Data Access
Data accessing for parameters and tables is different Parameter defined as: parameter Number_of_Students(courses) / BioE123 24, BioE234 21, BioE 345 17 /; I want to know the number of students taking BioE123 Number_of_Students(1) ---- WRONG Syntax Correct: Number_of_Students(BioE 123) I want to know the number of students taking BioE234 in 2003 Correct: StudentInfo(2002,BioE 234) This is a fundamental difference from the programming philosophy of MATLAB, FORTRAN, C etc.
10 BioE 494
Variable Declaration
Variables: Unknown quantities which are computed as the solution of the problem Variables are part of the equations (constraints and objective) defined in the optimization problem Syntax:
variable variable name(set name)
free (with no bounds): This is the default declaration positive variable negative variable binary variable integer variable
11
Equations
Used to define constraints and objectives An inequality is also defined as an equation Equation declaration
equations Equation1(set) name of the equation Equation2(set) name of the equation;
Equation definition
Equation_name(set).. actual equation ..
Equation types:
=e= =l= =g=
BioE 494
14 BioE 494
Press F9 to execute the code Errors are listed in the output list file and the solution is not reported 15
BioE 494
16 BioE 494
17 BioE 494