Hi,
I have a problem where I have to calculate the diameter of a pipe, using the equations I will find the diameter value that is a decimal number.
But the diameter I will use is the commercial value, always selecting the next commercial size of the value found by the equations.
Then I must analyze the cost of these pipes as a function of the diameter and the length of the mesh.
d (mm) preço($/m)
100 7,5
150 10,25
…
I don’t know how to enter this information.
If I must use the dollar, table, scalar, equation or upper and lower limit condition.
which of these methods is the best practice to use in GAMS because I would use (VLOOKUP, …, IF…) table between intervals in EXCEL.
My problem with the syntax in GAMS is how can I limit the result to being specific values, like for example:
the result of the diameter should be 150mm, or 200mm or 250mm or 300mm or 350mm or 400 or 500.
In my case the diameter is a variable, so reading the McCarl GAMS User guide I found two ways to solve the problem, however I don’t know how to write. Using
the function (.prior);
using the Control Variables;
Because each diameter have a price, the bigger the diameter of the tube, more expensive it is.
I already tried Tables (diameter,Price) but it is not a Set, so tables isn’t my solution.
If I use Dollar control, the code should be bigger. And I don’t know where I should declare this condition, something like that:
ex. dr(n,nd)=150 $ (dcal(n,nd)<=150)
if (150, 200] dr(n.nd) = 200
if (200, 250] dr(n.nd) = 250
if (250, 300] dr(n.nd) = 300
if (300, 400] dr(n.nd) = 400 and
if (400, 500] dr(n.nd) = 500
Not sure if I understand your question correctly, but maybe need something like this:
dr(n,nd)$(dcal(n,nd) gt 150 and dcal(n,nd) le 200) = 200;
etc.
Beware of the “ge” (greater or equal than) and “le” (less or equal than). Depending on what you want you also might need “gt” (striclty greater than) or “lt” (striclty less than)
So in your example:
if (150, 200] dr(n.nd) = 200
if (200, 250] dr(n.nd) = 250
What if the value is 200? Maybe you want “le” 200 = 200 and “gt” 200 = 250 (so there is no overlap for the value 200).