User Tools

Site Tools


gams:set_elements_are_strings_not_numbers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

gams:set_elements_are_strings_not_numbers [2007/04/04 12:46] (current)
Line 1: Line 1:
 +====== Set elements are strings, not numbers ======
  
 +Q: // If I have defined a set ''​t "time slots" /​1*10'';//​
 +
 +//Now I want to to  change this to something like //
 +
 +   set t "time slots" /1* "some multiplier of 10"/;
 +
 +//How can I do this?//
 +
 +You may try something like this 
 +
 +<​code>​
 +$if not set maxt $set maxt 10
 +set t "time slots" /1* %maxt%/;
 +display t
 +</​code>​
 +
 +To change the value of ''​maxt''​ from 10 to another number (i.e. 50), please add ''​--maxt050''​.
 +
 +Please also keep in mind that set elements are not numbers -- even if you choose labels that look like numbers. In fact, my recommendation is to avoid using set elements that look like numbers since it can cause confusion in different circumstances. If you write
 +
 +   Set t /t1 * t5/;
 +   Set i /i1 * i5/;
 +
 +you won't get the two confused. If you write
 +
 +   Set i /5 * 9/;
 +   Set j /3 * 8/;
 +
 +you'll be surprised to find that the order of elements in Set j is 5, 6, 7, 8, 3, 4. That's because the ordering comes from the collection of all unique set elements in a GAMS program -- and the order is defined by when they appear.
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/set_elements_are_strings_not_numbers.txt ยท Last modified: 2007/04/04 12:46 (external edit)