Hello,

how does one store a certain value in a set element determined by an

index given in a parameter? Example:

$EOLCOM //

// …

Set i nodes / 1 * 100 / ;

Alias(i,j) ;

Parameters

flows(i,j) flows between nodes

idx index of a node ;

// …

idx = 12 ;

// …

flows(idx,1) = 10 ; // → PROBLEM

I know I can use (for instance):

flows(i,1)$(i eq idx) = 10 ;

but it is neither elegant nor efficient (I guess – due to the fact

that GAMS probably cycles through all possible values of “i” and

checks whether the condition is met).

Unfortunately, the parameter “idx” is computed during post-processing

of the solution, hence I cannot specify the value of “flows(12,1)”

during its declaration/initialization.

Thanks for any help.

Best regards,

nvx

–~–~---------~–~----~------------~-------~–~----~

To post to this group, send email to gamsworld@googlegroups.com

To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com

For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en

-~----------~----~----~----~------~----~------~–~—

\

Hi,

The ‘flows(i,1)$(i eq idx) = 10 ;’ way is the only way to do ‘address’

access in GAMS. GAMS was not designed to efficiently support this kind

of access. You mention that you determine the index in post processing

after a solve. Why do you store the index rather than the set element

(e.g. in a dynamic subset). With that you can easily access the

appropriate set element.

Regards,

Michael Bussieck - GAMSWorld Coordinator

On Jun 13, 11:13 am, nvx wrote:

Hello,

how does one store a certain value in a set element determined by an

index given in a parameter? Example:

$EOLCOM //

// …

Set i nodes / 1 * 100 / ;

Alias(i,j) ;

Parameters

flows(i,j) flows between nodes

idx index of a node ;

// …

idx = 12 ;

// …

flows(idx,1) = 10 ; // → PROBLEM

I know I can use (for instance):

flows(i,1)$(i eq idx) = 10 ;

but it is neither elegant nor efficient (I guess – due to the fact

that GAMS probably cycles through all possible values of “i” and

checks whether the condition is met).

Unfortunately, the parameter “idx” is computed during post-processing

of the solution, hence I cannot specify the value of “flows(12,1)”

during its declaration/initialization.

Thanks for any help.

Best regards,

nvx

–~–~---------~–~----~------------~-------~–~----~

To post to this group, send email to gamsworld@googlegroups.com

To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com

For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en

-~----------~----~----~----~------~----~------~–~—

\

Dear Michael,

thank you for the suggestion. I’ll check GAMS user guide to see what

can/cannot be done using the dynamic sets. Maybe it will be better

than the “dollar-condition assignment.”

By the way, how about the efficiency of the dynamic set approach? Is

it faster than the dollar-condition?

Best regards,

nvx

On 15 Ävn, 09:43, Michael Bussieck wrote:

Hi,

The ‘flows(i,1)$(i eq idx) = 10 ;’ way is the only way to do ‘address’

access in GAMS. GAMS was not designed to efficiently support this kind

of access. You mention that you determine the index in post processing

after a solve. Why do you store the index rather than the set element

(e.g. in a dynamic subset). With that you can easily access the

appropriate set element.

Regards,

Michael Bussieck - GAMSWorld Coordinator

On Jun 13, 11:13 am, nvx wrote:

Hello,

how does one store a certain value in a set element determined by an

index given in a parameter? Example:

$EOLCOM //

// …

Set i nodes / 1 * 100 / ;

Alias(i,j) ;

Parameters

flows(i,j) flows between nodes

idx index of a node ;

// …

idx = 12 ;

// …

flows(idx,1) = 10 ; // → PROBLEM

I know I can use (for instance):

flows(i,1)$(i eq idx) = 10 ;

but it is neither elegant nor efficient (I guess – due to the fact

that GAMS probably cycles through all possible values of “i” and

checks whether the condition is met).

Unfortunately, the parameter “idx” is computed during post-processing

of the solution, hence I cannot specify the value of “flows(12,1)”

during its declaration/initialization.

Thanks for any help.

Best regards,

nvx

–~–~---------~–~----~------------~-------~–~----~

To post to this group, send email to gamsworld@googlegroups.com

To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com

For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en

-~----------~----~----~----~------~----~------~–~—

\