Bruce McCarl's GAMS Newsletter Number 19
GAMS 22.2 Release
GAMS Corporation has released versions 22.0, 22.1 and 22.2 which expanded
some language capabilities. Cumulative release notes are on the GAMS web site
at http://www.gams.com/docs/release/release.htm#22.2. Some of the new
features within these releases are discussed below. The software can
be downloaded from http://www.gams.com/download/.
The main new features are
- Performance improvements for very large and complicated loop structures.
- GAMS IDE modifications
- GDX data browser is faster and can sort indices by name vs. entry order
- A symbol shown in the GDX data browser can be written to an Excel file
- Navigation tree for the lst file.
- Ability to generate a chart based on an input file and data in a GDX file or based on an interactive process. Look in the IDE Help under Help Topics>Guided Tour>Charts for details
- Ability to manually select a table in GDX viewer and send it to EXCEL.
- New versions of BARON, CONOPT, CPLEX, DICOPT, EXAMINER, LGO and XPRESS. Some are minor upgrades but CONOPT has improved scaling, CPLEX has a new version (10) with improved MIP and infeasibility features and XPRESS has a new version with improved performance.
- Elimination of integer variable priorities during a run using X.prior=inf;
- Definition of new variable and equation attributes involving
- Slack variables (slack,slacklo,slackup)
- Infeasibility (infeas)
- Ability to use model names in a model equation list
Model first /eq1,eq2/;
Model second /first,eq3/;
- Model type MPEC now allows discrete variables and a new model type RMPEC relaxes these to continuous
- $IF check for the existence of a directory $IF DEXIST name
- McCarl GAMS User's Guide
- Changed to a different format permitting improved navigation
- Collapsed into a single .pdf and .chm file with working links in pdf
- The release notes also indicate new entries in the model and test model libraries.
See the release notes for details.
Speed and GAMS
I was recently working on a large and slow model. I found great success in speeding up certain types of calculations using a looping strategy. Namely I was computing
climatepesticide(crop,Aggregateregs,periods,gcm)=
sum(foraggregate(Aggregateregs,subreg),
climatepesticide(crop,subreg,periods,gcm)*
aggregatewtcr(Aggregateregs,SubReg,CROP));
and found this to be excessively slow using profile. (Note at the time I also had included $ conditions to suppress unnecessary cases but can't reconstruct them at this point and the time was still quite slow.)
In trying to speed this up I used the loop
tclimatepesticide(crop,Aggregateregs,periods,gcm)=0;
loop((rcrop(crop),allregforaggregate(Aggregateregs,subreg),periods,rgcm(gcm))
$( (not sameas(Aggregateregs,subreg))
and climatepesticide(crop,subreg,periods,gcm)),
tclimatepesticide(crop,Aggregateregs,periods,gcm)
= tclimatepesticide(crop,Aggregateregs,periods,gcm)+
climatepesticide(crop,subreg,periods,gcm)*
aggregatewtcr(Aggregateregs,SubReg,CROP));
climatepesticide(crop,Aggregateregs,periods,gcm)=
tclimatepesticide(crop,Aggregateregs,periods,gcm);
tclimatepesticide(crop,Aggregateregs,periods,gcm)=0;
achieving spectacular reduction (more than 99%) in statement execution time. The strategy
- Zeros an array and then adds into it using a loop carefully structured over non zero cases rather than summing.
- Adds into a temporary array different rather than the permanent array as this can be much faster. (GAMS apparently can slow down when jumping around in the sparse data array.) After the computation I then copy the results in all at once and then zero the temporary array.
CPLEX and a Basis
For a year or two I have noted a real degradation in the performance of a large model in repeated solves with CPLEX. The GAMS folks helped me out and found that benefits of an advanced basis can be enhanced using three CPLEX options.
| Turn off the dual simplex method
| lpmethod 1
|
| Cause more aggressive scaling to occur
| scaind 1
|
| Force basis use and suppress presolve
| advind 1
|
The real problem is the presolve and the basis do not always live well together and CPLEX used to suppress the presolve and just use the basis but does not as of verion 9 or so. Thus the last option is critical.
A large time savings (75%) resulted and perhaps others using advanced bases or repeated solves can benefit.
MIP Indicator Constraints in CPLEX
For many years it has been standard practice to conditionally include
constraints using integer/binary indicator variables using a "BigM" formulation.
aX - MY <= 0, X >= 0, Y in (0,1), and M a big number
Some have found that a tighter formulation of this speeds MIP solution time.
CPLEX has recently introduced an "indicator constraint" concept
in an effort to gain solution speed and GAMS has accommodated this at the moment through the CPLEX option file. Namely an indicator constraint identifies a binary variable/constraint pair where the binary variable turns the constraint on or off. For the time being, the couplings between binary variables and constraints are made through an option file as detailed at http://www.gams.com/solvers/cpxindic.htm.
FeasOpt in CPLEX
CPLEX has introduced a feature named FeasOpt that tries to suggest the least change in an infeasible model that would achieve feasibility. It selectively relaxes the bounds and constraints in a way that minimizes a weighted penalty function that you define. FeasOpt returns a suggested set of bounds and constraint ranges, along with the solution that would result from these relaxations.
The CPLEX 10.0 release notes
and http://www.columbia.edu/~dano/resources/cplex91_man/usrcplex/solveLP23.html elaborate, while the library model feasopt1 provides an example.
Be careful with Execute_Loadpoint
There is an aspect of Execute_loadpoint that one needs to be careful with. It not only reads levels and marginals of variables and equations, but also bounds, and scales. Thus it can redefine these items to those in model when it was solved if one is not careful. I believe GAMS may be working on changing this. It also merges the solution information and can introduce problems in the longstanding difficulties with GAMS and a solution merge/replace. For elaboration, see the section entitled "A Bug in GAMS" in my fourth newsletter.
Comparing Files
I often find a need to compare two files to see what is different between them. To do this I use the POSIX utility diff.exe that is distributed with GAMS. I implement it within the following small GAMS file (I name it compare.gms) and then execute like any other GAMS file. In turn diff compares file1.gms with file2.gms and reports any differences found into the log file.
$setglobal f1 c:\file1.gms
$setglobal f2 c:\file2.gms
$call '"%gams.sysdir%gbin\diff.exe" %f1% %f2%'
Grid Computing and MIPs
GAMS is developing a grid computing version that can take a MIP model and distribute the problems to be solved across a grid network of computers. This is working but still experimental and in the process of being written up.
Tom Rutherford Utilities
Tom Rutherford has moved his GAMS related page to http://www.mpsge.org/ where he has a number of utilities including interfaces to EXCEL, Graphic packages, and a mapping program. Materials on CGE modeling and MPSGE also appear there.
Courses offered
I teach a 3.5 day Basic GAMS
course at 9,200 feet in Frisco, Colorado June 12-15, 2006. That course is designed for beginners and those who have been working with GAMS casually. It deals mainly with GAMS usage in general, features for optimization and a little CGE.
A 3.5 day AAdvanced GAMS class will be offered in Frisco, Colorado August 14-17, 2006. That course is application independent mainly concentrating on the GAMS language, interfaces, graphing, report writing etc.
Further information and other courses are listed on http://www.gams.com/courses.htm.
Unsubscribe to future issues of this newsletter
To remove your name, please send an email to
mccarl-news-request@gams.com
containing unsubscribe on the subject line or unsubscribe through the
web form http://www.gams.com/maillist/newsletter.htm.
This newsletter is not a product of GAMS Corporation although it is
distributed with their cooperation.
May 8, 2006