How can some equations be removed from a model after the model statement?

How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

there are several ways to do this.

  1. define parameter p_eq1 and make p_eq1= 1; . Multiply eq1 by this parameter. When you want, change p_eq1 = 0;
  2. define artificial variable a_eq1 and make eq1= e= a_eq1; make a_eq1.fx= 0; . When you want, free a_eq1.lo= –inf; and a_eq1.up= inf;

Pio

From: Hossein
Sent: Tuesday, September 09, 2014 11:10 AM
To: gamsworld@googlegroups.com
Subject: How can some equations be removed from a model after the model statement?


How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.




Este mensaje no contiene virus ni malware porque la protección de avast! Antivirus está activa.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

I am not an experienced user but it should be as simple as naming explicitly each equation instead of using “all”: then solving for each model, including or excluding eq1, should make the job.



Best

M







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Hossein
Sent: Tuesday, September 09, 2014 16:10
To: gamsworld@googlegroups.com
Subject: How can some equations be removed from a model after the model statement?



How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is confidential, privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any printing, copying, dissemination, distribution, disclosure or forwarding of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and delete it from your system. Thank You.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Once an equation is in the model, you can still selectively include some or all instances of an equation by making its specification conditional on some test condition:

E.g. declare an equation

EQUATION AVDIST(ATRAD,R,T) “total miles traveled from depot to biorefinery”;

Specify it subject to certain $-conditions

AVDIST(ATRAD,R,T)$(TFORC(T)AFEAS(ATRAD)(SwTesting=0))… AVMILES_D(ATRAD,R,T)=E= [equation RHS follows here];



This equation only occurs for T in the forecast horizon TFORC, for feasible members of ATRAD, and if the switch SwTesting is 0.

More simply, you could do something like the following to use the setting of SwTesting to turn an equation on and off.



AVDIST(ATRAD,R,T)$(SwTesting=0)… AVMILES_D(ATRAD,R,T)=E= [equation RHS follows here];



Note 1: Somewhat like functions or variables in strongly-typed programming languages, in GAMS equations must first be “declared” and then “specified or defined.”

This gives you the latitude to declare general equations and include them in your model, but to make the actual instance of the equations used be dependent on the specific conditions in the equation specification.



Note 2: Since the model is not really created until the SOLVE statement, you have the ability to redefine control-settings like SwTesting after the MODEL statement but before the SOLVE statement.



Note 3: Actually, the same approach can use $-conditions in an equation specification to selectively include or exclude particular portions of an equation at SOLVE time, depending on parameter values or set membership.





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Hossein
Sent: Tuesday, September 09, 2014 10:10 AM
To: gamsworld@googlegroups.com
Subject: How can some equations be removed from a model after the model statement?



How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hossein:



Try to look in the release notes, http://www.gams.com/docs/release/release.htm, and search for New model definition features.



In your case you can define a new model



Model test1 / all - eq1 /;



But there are many similar ways to define one model from another by adding or deleting blocks of equations.



Regards



Arne


Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: adrud@arki.dk



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Hossein
Sent: Tuesday, September 09, 2014 4:10 PM
To: gamsworld@googlegroups.com
Subject: How can some equations be removed from a model after the model statement?



How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hossein,

Here is some text you can paste onto the end of the transport model from the GAMS model library. It illustrates what you’re trying to do.

model m2 / transport - supply /;
solve m2 using lp min z;

model m3 / transport - demand - supply /;
solve m3 using lp min z;

Also, check the release notes at

http://www.gams.com/docs/release/release.htm

and search for “model list edits”.

-Steve

On Tue, Sep 9, 2014 at 10:10 AM, Hossein wrote:

How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

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

I really appreciate everything that group friends have done. I found my answer.

On Tuesday, September 9, 2014 6:40:05 PM UTC+4:30, Hossein wrote:

How can some equations be removed from a model after the model statement?

For example, the model ‘test’ is defined as follows:

Model test /all/;

After that, we may need to remove the equation named ‘eq1’ from this model.

Thanks in advance;

Hossein


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.