Return value of max in "optimize("Description", default, min, max, step)"

Hi All,

I have a list of variables getting optimized result by

variable1 = optimize( "Description", default1, min, max, step );
variable2 = optimize( "Description", default2, min, max, step );
.....
.....
......
......
variable100 = optimize( "Description", default100, min, max, step );

I would like to have a way to return a value that is something like

returned_value = max(default1, default2, .......default100);

and the returned_value is the largest number among default1 to default 100.

Is it possible? Thanks!

@wtchung I'm wondering about what you are trying to do with 100 variables (to be optimized :scream:)

Anyway, instead of 100 individually named variables, one alternative is the use of a matrix: 1

m = Matrix(101, 2, Null); // element 0 is not used for laziness (so index used will be 1/100)
m[  1][0] = 21; // default 1
m[  2][0] =  7; // default 2
m[  3][0] = 12; // default 3
m[  4][0] = 96; // default 4
// .... etcetera
m[ 99][0] = 14; // default 99
m[100][0] = 50; // default 100

maxValue = m[1][0]; // init with the first true(assigned)  value
minValue = m[1][0];
for(i=1; i <=100; i++) 
{
  minValue = IIf(IsTrue(m[i][0]), Min(m[i][0], minValue), minValue);
  maxValue = IIf(IsTrue(m[i][0]), Max(m[i][0], maxValue), maxValue);
}  

_TRACE("Min Value: " + minValue + " - MaxValue: " + maxValue);

In any case, if you try to run an optimization using 100 variables, you'll get this error:

immagine

1) Keep in mind that normally matrix rows/columns elements are accessed using an index from (0... number of rows-1) (0... number of col-1), but in this example, I skip row[0] to make it more consistent with individual variables numeration (default1, default2, etc.).

Original poster should really do the math and consider that 1019 - is 10 000 000 000 000 000 000 combinations. Assuming that you've got super fast system that only needs 1 second per step this means 317 000 000 000 years to complete optimization (assuming it is exhaustive). Even using smart non-exhaustive optimization algorithm you simply can't expect better result than cutting this by factor of million (with some extreme luck) which still would give you hundreds of thousands of years.

2 Likes