ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trouble getting solver to load a model (https://www.excelbanter.com/excel-programming/284910-trouble-getting-solver-load-model.html)

Don C[_3_]

Trouble getting solver to load a model
 
I have written my solver to work in a loop. During each loop I need to adjust size of the "By Changing Cells" array and also one of the constraints. I have no problems with getting the program to adjust the "By Changing Cells" array. The constraint however is different.

I have my program change the formula in the saved model area to accomadate the new array size, (it looks like this {=G44:G61=0}). Now, when I load the saved model, I get this error "SOLVER: An Unexpected internal error occurred, or available memory was exhausted". It doesn't matter if I try to load a model after the program has adjusted my new constraint or if I type in all my constrains it the main solver form then save them then try to reload them. I get the same error.

Can anyone give me some advice? Or do I have to have my program write a constraint for each cell in the array (i.e. =G44=0, =G45=0, . . . , =GXX0)

Tushar Mehta

Trouble getting solver to load a model
 
Don't know if this will help, but when I have a loop of some sort using
Solver, I clear the existing Solver model with a SolverReset at the top
of the list. Then, I create the next one customized to the conditions
specific to the current loop.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have written my solver to work in a loop. During each loop I need to adjust size of the "By Changing Cells" array and also one of the constraints. I have no problems with getting the program to adjust the "By Changing Cells" array. The constraint however is different.

I have my program change the formula in the saved model area to accomadate the new array size, (it looks like this {=G44:G61=0}). Now, when I load the saved model, I get this error "SOLVER: An Unexpected internal error occurred, or available memory was exhausted". It doesn't matter if I try to load a model after the program has adjusted my new constraint or if I type in all my constrains it the main solver

form then save them then try to reload them. I get the same error.

Can anyone give me some advice? Or do I have to have my program write a constraint for each cell in the array (i.e. =G44=0, =G45=0, . . . , =GXX0)


Dana DeLouis[_3_]

Trouble getting solver to load a model
 
Changing the "Saved Model" area is "usually" not the way to change a model
in a loop. But, as a suggestion...
Try removing the "{" and the "})" in your constraint. (
{=G44:G61=0}) ) These are usually used in the last cell to hold the
values of your solver options. (It's an array of options).
Solver usually stores the cell values using Absolute reference. You may
want to experiment and do the same.
If you are using Excel 97 or above, make sure your worksheet is using A1
reference, and not R1C1 reference.
I agree with Tushar that's it's probably best just to reset the model and
start fresh with each loop.

--
Dana DeLouis
= = = = = = = = = = = = = = = = =


"Don C" wrote in message
...
I have written my solver to work in a loop. During each loop I need to

adjust size of the "By Changing Cells" array and also one of the
constraints. I have no problems with getting the program to adjust the "By
Changing Cells" array. The constraint however is different.

I have my program change the formula in the saved model area to accomadate

the new array size, (it looks like this {=G44:G61=0}). Now, when I load
the saved model, I get this error "SOLVER: An Unexpected internal error
occurred, or available memory was exhausted". It doesn't matter if I try to
load a model after the program has adjusted my new constraint or if I type
in all my constrains it the main solver form then save them then try to
reload them. I get the same error.

Can anyone give me some advice? Or do I have to have my program write a

constraint for each cell in the array (i.e. =G44=0, =G45=0, . . . ,
=GXX0)



Don C[_3_]

Trouble getting solver to load a model
 
Thanks for the input. I did do exactly as you said and it works great now. I didn't know about the SolverAdd code to add constraints. Now I just set the whole model up in the code.

I did find that the problem with loading the model didn't have anything to do with that array function I was tring to load. It was with the solver options (the last cell in the saved model). For some reason, when you try to load a model with different solving Options, (rather then the defaults) you get the unexpected internal error.

Thanks again.

Don C[_3_]

Trouble getting solver to load a model
 
Thanks for the input. Unfortunatly, I did need that G44:G61=0 in the {} brackets, because that is an array function.

See my reply to Tushar, I found that the problem that was giving me the error was actual the cell holding the solver options array. If you save a model with Assume Non-Negative checked on and Use Automatic Scaling checked on and Central Derivatives Checked on (leave the rest set as defaulted), then try to load it back up, you will get the same error I did. I got the error when I ran it in my code and when just doing it manually.

Thanks for the reply.


All times are GMT +1. The time now is 06:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com