A client recently asked if was possible to re-optimize the final matrix from an SLP model outside of GRTMPS.  I’m not sure why he wanted to do it, but I run stand-alone optimizations from time to time, mostly to replicate and debug suspected problems with the optimizers.  It is also a rather handy thing to know when you have large linear models (like distribution problems) as you can edit the bounds, for example, to see if that makes something feasible, without having to regenerate the matrix, thereby bypassing all the data preparation etc.    You can also turn on output files that you forgot - like the ROWLIST or tinker with the controls like maximum iterations or using the barrier instead of simplex algorithm.
  
Running the optimizer in stand-alone mode requires just two inputs –a matrix to solve and a command file to instruct it to do so.  All three of the optimizer executables that are available with GRTMPS have been configured to expect an LP problem written as an MPS format matrix.   This is the MTX file.  If you are running a recursed model, there is also the BCD file with the final assumed values.  Mark one (or both) to be kept via the Output General panel. 
 
90 SaveOutputFiles  
 
To get your command file, also keep the “Misc. Run Files”.  After the run, look in the output folder (right-click on the record in the Queue Manager or on the Output node in the g5 model tree).  The simplest command file is LPFILE01.   It just reads a matrix and optimizes it.   The commands in the file will vary depending on which optimizer - HSLP, H/XPRESS or H/CPLEX - is active, and what options you have set.
 
Here is a an LPFILE01 command file for HXPRESS generated for one of the demo models, with some notes on the on key elements.:
 
Run_00    run-id
SETICV  NMXTRA  0001000    
SETICV  ICRASH  0    
INPUT   Read the Matrix
SAVE    
MINIM   Minimize the objective function
BASISOU BASISNT.    
SETCCV  DATNAM  CASE0001    
HPRINT   Write out the solution print
SETICV  OMNIMAT 1    
OMNIOUT 16CHAR    
QUIT    
 
I’m not marking up the whole thing because I don’t want to get into all the detail that explaining some of that requires so please take it as a "this is what it is",  for now.
 
Copy the Matrix (MTX or BCD) and the LPFILE01 file to a convenient folder.  Rename the matrix to RECOUT1.    You can call the command file whatever you like (but more convenient to have a short name with no spaces).  I do the optimizations in a Command Prompt window.   Open one (search in the App list via the Start menu if you don't have this pinned already.) 
 
Navigate to where you have stored your files using “cd” (change directory).    The “dir” command will give you a list of what is in the folder so you know you are in the right place
.  
90 CommandPromptDir
 
The optimizer executables are installed in the GRTMPS application folder.  You can identify that location from the user interface via Tools: System Tools: GRTMPS System Folders.   The optimizer has to stay in the installed location so that it is with the licence files etc.   To run the optimizer in your working directory, you will need to give the full path name.   I’ve written a tiny “.bat” file to for each optimizer to save having to type it out every time. This is the one for H/XPRESS. 
 
"C:\Program Files (x86)\Haverly\GRTMPS\HXpress.exe" %1
 
There have to be quotes around the path\executable name because of the spaces. "%1" is for giving a parameter - the name of the command file -  when the bat is run. 
 
Type RunHxpress LPFILE01 - or whatever name you gave your command file -  like so:
90 RunBatFile 
 
And the optimization will start.
90 HXPRESSRunning
  
The beginning of the optimizer log gives the problem statistics.  (When you run from within GRTMPS you can see this in the LST file.).   It will probably scroll out of sight as the optimization iterations are echoed to the screen, but you can use the (barely perceptible in Windows 11)  scroll bar on the right of the window to look back at previously displayed lines.   (And you can use the up-arrow key to retrieve commands that you have typed in previously.)
 
The demo model is very small, and so solves very with only a few iterations.
 
 90 HXPRESSFinished
 
 
As well what is echoed to the console, there will be some output files created, as you can see by checking the contents of the folder afterwards.   
 
90 DirWithOutput
 
 
 Optstats.dat is a small summary of the results, as would be used to fill in the run KPIs in the Queue Manager.  

90 TypeOptStats
 
PROBFILE contains the saved Optimization problem and SOLFILE contains the solution.  They are binary files so you can’t just open them.   What you can look at is the  solution PRINT file which is made in response to the HPRINT instruction.  You can look at this to see what values the variables have taken and which constraints are limiting. It will also show you what is unbounded or infeasible if the solution is not optimal.   (In a G5 run this is often echoed into the LST file for the First and Last passes, as set on the Optimizers: Advanced panel, or it can be saved as a separate file by ticking SPR on the Output: General panel).   If you have simply copied the matrix and command file, then the objective value will be the same as you see in GRTMPS.   
 
Once you have replicated the original run, you can start changing things.    The matrix can be edited – it's just a text file – so that you can optimizer a slightly different problem.  This is useful if the generate times are long.  For example, you can check if relaxing a BOUND on a purchase/sale vector or the RHS on a unit capacity equation will make a model that isn’t solving go feasible.  (Better, however, to stay out of changes to the main body of the model in the COLUMN section as there are many inter-related numbers – if you want to change a process yield or pool quality assumption– better to regenerate. And do remember that there won't be any recursion either, so if the matrix came from an SLP model you won't know if the solution is converged or not).  
 
You can also edit the command file.  For example, suppose you want to look at your matrix in equation format – a ROW file – but discover that you had not set it to keep.    If you compare the command file to one from a run where a ROW was made, you will see that for H/XPRESS you just need to add “ROWLIST” after “INPUT”.    If your RECOUT1 file is a copy of the MTX, then you will have the ROW for the original problem.  If your RECOUT1 is a copy of the BCD file, then you will have the after-recursion ROW file.  If that is all you want, and you don’t want to bother with optimizing again, you can delete the rest of commands, like so: 
 
Run_00
INPUT 
ROWLIST             
QUIT
 
There are, of course, many things that you can adjust about the optimization too – such as maximum iterations, using dual or primal simplex, reading/writing a basis file etc.  If you are a GRTMPS user on support and would like to know more, please ask.  I do intend to come back to this topic in the future, to talk about commands, and using REVISE files to replicate intermediate recursion passes, and BASIS files to speed up the optimization…. Until then,
 
Regards 

From Kathy's Desk. 

P.S.  Type "exit" at the prompt to terminate your Command window.

15th March 2023
(Revised 5th January 2024) 
 
 
 
Comments and suggestions gratefully received via the usual e-mail addresses or here.
You may also use this form to ask to be added to the distribution list so that you are notified via e-mail when new articles are posted.