0

I have set i/1*7/ and parameter u(i) /1 15,2 5,3 15,4 30,5 21,6 30,7 11/

I want to find maximum element of u(i) , i use 'smax' , I write this code:

  set j/1*7/;
  parameter u(i) /1 15,2 5,3 15,4 30,5 21,6 30,7 11/;
  scalar max_val;
  max_val=smax(j,u(j)); 

To find the index of maximum element, I wrote this

  set posmax(j)  'position of largest element on deg(j)';
  posmax(j) = deg(j) = max_val ;

There are two maximum members here, but I just want one.for example iwant to have posmax=6 , or posmax=4 . but i dont want posmax = 6,7.

What command should i use?

How can I access the first member?

In general, how can I access a particular member in a subset?

i write posmax('1') but i get error.

Tom Zych
  • 13,329
  • 9
  • 36
  • 53

1 Answers1

0
Scalars mypos;
Mypos=smin (j$posmax(j) ,j.val);
Richard
  • 177
  • 1
  • 9