How to stop a loop before it reaches infeasible solution.

Dear Programmers,

An example of loop as seen in the following, I want to stop at the last “s”, for example s=0.6, that makes feasible solution, how to stop or abort the loop before an infeasible solution takes place? So there is no need to run the remaining s=0.8, and s=1. Thank you!


scalar s;

for (s = 0 to 1 by 0.2,

solve abc using nlp maximizing obj;


);

Best regards,
Linstro


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.

Hi Linstro



Finding out if a model is infeasible before you run it, might be hard…

However, you can find the first one that is infeasible and stop after that one using the model status (modelstat) in a while loop. Model status equal to 6 is infeasible.

The model status can be found as follows:



Parameter mymodel_status;

** Initialize the status to 1 (optimal), so we can start the while loop:



While (mymodel_status eq 1,

Solve mymodel….

Mymodel_status = mymodel.modelstat;

);



You could also

Hope this helps.

Cheers

Renger



PS. Here are the possible values of status



Integer number that indicates the model status.

1 Optimal

2 Locally Optimal

3 Unbounded

4 Infeasible

5 Locally Infeasible

6 Intermediate Infeasible

7 Intermediate Nonoptimal

8 Integer Solution

9 Intermediate Non-Integer

10 Integer Infeasible

11 Licensing Problem

12 Error Unknow n

13 Error No Solution

14 No Solution Returned

15 Solved Unique

16 Solved

17 Solved Singular

18 Unbounded - No Solution

19 Infeasible - No Solution





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Linstro Forren
Sent: Donnerstag, 7. Mai 2015 17:51
To: gamsworld@googlegroups.com
Subject: How to stop a loop before it reaches infeasible solution.



Dear Programmers,



An example of loop as seen in the following, I want to stop at the last “s”, for example s=0.6, that makes feasible solution, how to stop or abort the loop before an infeasible solution takes place? So there is no need to run the remaining s=0.8, and s=1. Thank you!





scalar s;



for (s = 0 to 1 by 0.2,



solve abc using nlp maximizing obj;





);



Best regards,

Linstro


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.

Thank you Renger for your answer.

Best regards
Linstro

On 8 May 2015 at 11:27, Renger van Nieuwkoop wrote:

Hi Linstro



Finding out if a model is infeasible before you run it, might be hard…

However, you can find the first one that is infeasible and stop after that one using the model status (modelstat) in a while loop. Model status equal to 6 is infeasible.

The model status can be found as follows:



Parameter mymodel_status;

** Initialize the status to 1 (optimal), so we can start the while loop:



While (mymodel_status eq 1,

Solve mymodel….

Mymodel_status = mymodel.modelstat;

);



You could also

Hope this helps.

Cheers

Renger



PS. Here are the possible values of status



Integer number that indicates the model status.

1 Optimal

2 Locally Optimal

3 Unbounded

4 Infeasible

5 Locally Infeasible

6 Intermediate Infeasible

7 Intermediate Nonoptimal

8 Integer Solution

9 Intermediate Non-Integer

10 Integer Infeasible

11 Licensing Problem

12 Error Unknow n

13 Error No Solution

14 No Solution Returned

15 Solved Unique

16 Solved

17 Solved Singular

18 Unbounded - No Solution

19 Infeasible - No Solution





From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Linstro Forren
Sent: Donnerstag, 7. Mai 2015 17:51
To: gamsworld@googlegroups.com
Subject: How to stop a loop before it reaches infeasible solution.



Dear Programmers,



An example of loop as seen in the following, I want to stop at the last “s”, for example s=0.6, that makes feasible solution, how to stop or abort the loop before an infeasible solution takes place? So there is no need to run the remaining s=0.8, and s=1. Thank you!





scalar s;



for (s = 0 to 1 by 0.2,



solve abc using nlp maximizing obj;





);



Best regards,

Linstro


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.

\

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.