# finding a certain element of a table in gams

 0 In a GAMS program, I have a table with two rows and ten columns. the first row is the prices and the second row is the profit. I use the "Smax" to find the maximum profit but I can not find the price consistent with maximum profit please help me to find the corresponding price asked 02 Jun '14, 17:04 aazad 11●2 accept rate: 0% @aazad: Do you need the corresponding index or would just the corresponding price suffice as well? Also, does the profit array contain unique elements or not? (04 Jun '14, 15:22) Ehsan ♦

 3 Hi, I hope this solves your problem: set row / price, profit / col / c0*c9 / idxMaxProfit(col) ; parameter t(row,col), priceMaxProfit(col); * Random data t(row,col) = uniformInt(2,8); scalar maxProfit; maxProfit = smax(col,t('profit',col)); * All columns that have the maximum profit idxMaxProfit(col) = t('profit',col) = maxProfit; * Prices of the columns with the maximum profit priceMaxProfit(idxMaxProfit) = t('price',idxMaxProfit) display t,idxMaxProfit,priceMaxProfit;  Best, Lutz answered 11 Jun '14, 12:13 Lutz Westermann 41●4 accept rate: 0% 1 @Lutz, great to see GAMS people here. Your input is most needed! (11 Jun '14, 13:53) Marco Luebbecke ♦
 toggle preview community wiki

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×51