Solve and optimize in loop

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b) and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


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.

You cannot put solve statement or equations in the loop statements.
So, take the solve statement out of the loop and it should work.

On Wed, Nov 16, 2011 at 6:53 AM, hh.mad@lycos.com wrote:

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b) and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


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.

\

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.

Sungai,

You should have a look at the models in the GAMS model library. For
example, the model icut has a solve within a loop, etc.

-Steve

On Wed, Nov 16, 2011 at 9:53 AM, hh.mad@lycos.com wrote:

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that
is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b
is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b)
and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not
familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


“gamsworld” group.
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.




– Steven Dirkse, Ph.D. GAMS Development Corp., Washington DC Voice: (202)342-0180 Fax: (202)342-0181 sdirkse@gams.com http://www.gams.com

Thanks for your insight.
My solution shouldn’t be integers. And to change it to MIP model could be painful for me.
Does icut also cover non MIP?

regards,
sungai.

On Nov 17, 2011, Steven Dirkse wrote:

Sungai,

You should have a look at the models in the GAMS model library. For
example, the model icut has a solve within a loop, etc.

-Steve

On Wed, Nov 16, 2011 at 9:53 AM, hh.mad@lycos.com wrote:

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that
is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b
is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b)
and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not
familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


“gamsworld” group.
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.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com


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.


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.

Thanks for your insight.
My solution shouldn’t be integers. And to change it to MIP model could be painful for me.
However, it is intended to be an equilibrium model.
Does icut also cover non MIP?

regards,
sungai.

On Nov 17, 2011, Steven Dirkse wrote:

Sungai,

You should have a look at the models in the GAMS model library. For
example, the model icut has a solve within a loop, etc.

-Steve

On Wed, Nov 16, 2011 at 9:53 AM, hh.mad@lycos.com wrote:

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that
is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b
is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b)
and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not
familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


“gamsworld” group.
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.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com


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.

\

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.


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.

Another thing, it is supposed to be an equilibrium model
Thanks. Sorry for double message.

regards,
sungai.

On Nov 17, 2011, hh.mad@lycos.com wrote:

Thanks for your insight.
My solution shouldn’t be integers. And to change it to MIP model could be painful for me.
Does icut also cover non MIP?

regards,
sungai.

On Nov 17, 2011, Steven Dirkse wrote:

Sungai,

You should have a look at the models in the GAMS model library. For
example, the model icut has a solve within a loop, etc.

-Steve

On Wed, Nov 16, 2011 at 9:53 AM, hh.mad@lycos.com wrote:

Hello all,

I am a beginner, trying to write this in GAMS.
I have a set t(time) and other sets and I want to calculate something that
is growing over time.
p(0) (p at t = 0) is the initial value.
X is the growing factor, a constant.
O(a,b) is a variables that needs to be optimized over time period, a and b
is set names
So I wrote something like:

//the empty lines contains model
//…
//…
model mymodel/ALL;
loop(t,
solve problem maximizing my objective function; // to get O(a,b)
and other variables
p(t) = (1+X) * p(t-1) - O(a,b,t-1);
);

I know how to do this in C/C++ with while do loop or for loop, but I am not
familiar yet with GAMS syntax.
Thanks.

regards,
sungai.


“gamsworld” group.
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.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com


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.

\

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.


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.