


However, variable attributes are allowed. Note Logical conditions used with the dollar operator cannot contain variables. These topics are covered in later sections of this chapter. Conditional expressions may be used in the context of assignments, indexed operations and equations. Logical conditions may take various forms, they are introduced in the next section. To make it clear, this conditional assignment may be read as: ' given that b is greater than 1.5, a equals 2'. If the condition is not satisfied, no assignment is made. Note that the term is the scalar a and the logical condition is the expression \((b > 1.5)\). This can be written in GAMS using the dollar operator as follows. The dollar operator may be read as under the condition that the following logical_condition evaluates to TRUE (or is unequal 0).Ĭonsider the following simple condition, where a and b are scalars. Here, term can be a number, a (indexed) symbol, and also a complex expression. The general syntax for a conditional expression is: term $ logical_condition The dollar operator is one of the most powerful features in GAMS. These can be found in the chapter Programming Flow Control Features. Programming flow control features such as the if statement, the loop, the while statement, and the for statement are not covered in this chapter. We will conclude the chapter by showing that in certain cases conditions may be modeled using filtering sets instead of the dollar operator. Next, we will discuss how dollar conditions are used to build conditional assignments, conditional indexed operations and conditional equations. This chapter is organized as follows: We will introduce the general form of the dollar condition first and then we will focus on the various types of logical conditions. Exceptions such as these may easily be modeled with a logical condition combined with the dollar operator '$', a very powerful feature of GAMS introduced in this chapter. For example, heavy trucks may not be able to use a particular route because of a weak bridge, or some sectors in an economy may not produce exportable products. The index operations already described are very powerful, but it is necessary to allow for exceptions of one sort or another. This chapter deals with the way in which conditional assignments, expressions and equations are made in GAMS.
