Saving Time of when best solution was found & log and lst files with unique names

Solver related questions
Post Reply
PondersnWonders
User
User
Posts: 7
Joined: 10 months ago

Saving Time of when best solution was found & log and lst files with unique names

Post by PondersnWonders »

Hi everyone,

I created a model that is nonlinear and nonconvex through the BARON solver with optcr=0.001.

Im exploring different parameter combination instances through MATLAB which then calls my GAMS script (that contains the NLP/nonconvex model) to solve the model. Once the optimal solution or a feasible solution that meets the specified termination criteria is found, results are stored as variables and saved to my MATLAB script. So far, I've been able to store my solution (decision variables & obj val), theoretical upper bound, and total run time. The disadvantage to my method is that the lst and log files are not saved since these files are overwritten every time MATLAB calls the GAMS file to solve a specified instance.

The few times I've directly ran my model in GAMS, I've been able to look at the iteration log and noticed that the best solution is found relatively quickly (e.g., the best solution was found in 5 min, but the solver for ran for several hours more because it hasn't satisfied the specified optcr or reslim). This is an important metric to record for my analysis.

I cant find anything that explains how to save time of best solution was found. Additionally, it would also be nice to save all log and lst files (possibly have GAMS specify a unique file name to prevent it from overwriting each time). Any help on this is greatly appreciated!
User avatar
bussieck
Moderator
Moderator
Posts: 1043
Joined: 7 years ago

Re: Saving Time of when best solution was found & log and lst files with unique names

Post by bussieck »

I don't think there is a general "time saving" option in BARON. Even though your best incumbent is found quickly BARON still needs to move the dual bound to reach the optimality tolerance. That can sometimes take a long time, even if you already know and hold the optimal solution. If you could share a typical instance perhaps someone (perhaps even the BARON developer) can experiment with this and see if there are some good options to improve the running time.

GAMS has command line options that allow you to give specific names to the log (lo=2 or 4 lf=filename) and lst (output=filename) files. See https://www.gams.com/latest/docs/UG_Gam ... SAOlogfile and https://www.gams.com/latest/docs/UG_Gam ... MSAOoutput for details.

-Michael
PondersnWonders
User
User
Posts: 7
Joined: 10 months ago

Re: Saving Time of when best solution was found & log and lst files with unique names

Post by PondersnWonders »

Hi Michael, thanks for replying! When you mean to share an instance, do you mean to share the entire GAMS script here?

I'm still getting used to the GAMS syntax. Is it possible to name the file based on a given parameter? For example, say we set the parameter 'instance'=6. When the log or lst file is saved, it will be titled "ResultsV6.log" or "ResultsV6.lst" . This way I can loop through several test instances using the same MATLAB code and ill have a folder with several log files corresponding with the different test instances. (I.e., ResultsV1.log, ResultsV2.log,...).

bussieck wrote: 10 months ago I don't think there is a general "time saving" option in BARON. Even though your best incumbent is found quickly BARON still needs to move the dual bound to reach the optimality tolerance. That can sometimes take a long time, even if you already know and hold the optimal solution. If you could share a typical instance perhaps someone (perhaps even the BARON developer) can experiment with this and see if there are some good options to improve the running time.

GAMS has command line options that allow you to give specific names to the log (lo=2 or 4 lf=filename) and lst (output=filename) files. See https://www.gams.com/latest/docs/UG_Gam ... SAOlogfile and https://www.gams.com/latest/docs/UG_Gam ... MSAOoutput for details.

-Michael
PondersnWonders
User
User
Posts: 7
Joined: 10 months ago

Re: Saving Time of when best solution was found & log and lst files with unique names

Post by PondersnWonders »

Tried to modify the GAMS code so I can save the log and lst files (log file for now...). LocationAllocationModelv9_ColdStart.gms is the GAMS file name.

I previously define a new parameter called 'instance'

instance /456/
.....
.....
Model TestModel /all/;
Option reslim=100;
Option optCR=0.001;
Option MINLP = BARON;
Option threads=30;
Option decimals=8;

Solve TestModel using MINLP maximizing objective1;

runTime = TestModel.resusd;
estimatedUpperBound = TestModel.objest;
absoluteGap = abs(TestModel.objest-TestModel.objval);
relativeGap = absoluteGap/(abs(TestModel.objest));
solutionType = TestModel.modelstat;
solverStatus = TestModel.solvestat;

$call gams LocationAllocationModelv9_ColdStart.gms lo=2 lf=ResultsV$instance$.log



Issue:
The code above produces the log file titled 'ResultsV$instance$.log' instead of 'ResultsV456.log'.
Furthermore, it seems the $call.... line is producing thousands on folders in the current directory that I cannot terminate without having to turn the computer off.
Post Reply