Switching between models gives "error processing objective"

18 views
Skip to first unread message

chris.man...@gmail.com

unread,
May 22, 2017, 3:02:18 AM5/22/17
to AMPL Modeling Language
Hi,

I am trying to automate a process that involves iteratively solving two different models. Roughly speaking, the process goes:

1. Solve the "Master LP" (MLP)
2. Use some of the decision variables of the MLP as parameters for the "attacker sub-problem" (ASP)
3. Solve the ASP
4. Use some of the dual variables related to the ASP to define new constraints for the MLP
5. Repeat 1-4 until no new constraints are added, then return the full MLP

I got everything working as separate models, where I would solve one model, then run a blanket reset and solve the other. However, ideally I would like to have everything run as one single entity, so I thought that I could do this:

1. Load model and data files that contain all the common input data between the two models
2. Load and solve the MLP
3. Purge the parts specific to the MLP
4. Load and solve the ASP
5. Purge the parts specific to the ASP
6. Repeat as per normal

The problem has come in steps 3-4: After I purge the required components (two variables that, between them, run through the entire MLP), I load the model for the ASP. Having done so, then the very next command I try to run always* results in the following error:

> Error executing "let" (or "display", or whatever) command:
> error processing objective yLim:
>     no value for dir

* Commands that remove the objective function seem to run ok (e.g. purging one of the component variables), but anything else - including trying to set a value for dir - give the error.

The objective is defined as

> maximize yLim: dir * yalt[ps];

where dir and ps are params and yalt is the only var in the model. The values of dir and ps are set a little bit later on, just before the solve command, and that worked fine when I reset and re-loaded everything, but when I try to keep the common data loaded I get the above error.

I did a test where I reset and re-loaded all the data before loading the ASP model, and that seemed to fix the problem. However, doing so defeats the purpose of managing it that way. Also, I'm confused as to why this is a problem in this circumstance, especially since I would be trying to set the value for dir soon afterwards anyway. Can anyone explain this/offer a solution?

Regards,
Chris

Robert Fourer

unread,
May 23, 2017, 1:30:05 AM5/23/17
to am...@googlegroups.com
It is not possible to determine the cause of the "no value for dir" error from only the information given. Can you post your model file and AMPL command script?

I can say however that in general the best approach is to read in both the master and subproblem once at the beginning, and then switch between them using named problems as described in section 14.5 of http://ampl.com/BOOK/CHAPTERS/17-solvers.pdf and shown in the examples at http://www.ampl.com/NEW/LOOP2/.

Bob Fourer
am...@googlegroups.com

=======

chris.man...@gmail.com

unread,
May 23, 2017, 7:55:46 PM5/23/17
to AMPL Modeling Language, 4...@ampl.com
Hi Bob,

Thanks for the reply. Just skimming through 14.4 and onwards I see that it covers a very similar situation to mine. I will read the chapter more thoroughly, and if that doesn't provide any answers I'll post up my code.

Chris
Reply all
Reply to author
Forward
0 new messages