|
From: | Kevin Hunter |
Subject: | Re: [Help-glpk] manipulating parameter indices |
Date: | Mon, 02 Jul 2012 06:34:44 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
At 6:58pm -0400 Sat, 30 Jun 2012, Kevin Hunter wrote:
At 12:59am -0400 Sat, 30 Jun 2012, Glpk Xypron wrote:set EFF, dimen 5; set inputs := setof{(i,p,v,o,e) in EFF}i; set process := setof{(i,p,v,o,e) in EFF}p; set vintage := setof{(i,p,v,o,e) in EFF}v; set outputs := setof{(i,p,v,o,e) in EFF}o; set S := setof{(i,p,v,o,e) in EFF} (i,p,v,o); param eff{(i,p,v,o) in S} := sum{(i,p,v,o,e) in EFF}e;
Most excellent! I was not aware that I could use sets in this manner. That is exactly the functionality for which I was searching. Thank you.
I'm now concerned about the efficiency of this approach. As of yesterday afternoon, I have used this approach to implement my model in GMPL and have created an analogous version in Pyomo. I'm using the approach you gave me above to create sparse sets over my whole model, and am similarly using sparse sets in the Pyomo implementation.
For a fairly small input data file (18k rows, 16k cols, 94k nz), the GMPL avenue takes about 40 seconds to generate and solve on my machine, while Pyomo takes about 11 seconds to generate and solve, /including/ using GLPK as the solver. (This is a stable average of ~10 runs.)
For a smaller data file, I note that GMPL is slightly faster (2 seconds vs Pyomo's 3). (Again, stable average.) Given that GLPK is written in C, and Pyomo in Python, this leads me to suspect that I'm not using GMPL appropriately.
Is there common wisdom on what I might be doing wrong? If I had to guess, I'd suspect I'm hitting some O(n) wall in regards to GMPL's just-in-time instantiation of derived set and parameter elements.
If anyone's interested in looking at code rather than my vague suppositions, I've posted what I'm working with:
http://cygnus.ce.ncsu.edu/~kevin/tmp/model.zip Thanks much for any insights. Kevin
[Prev in Thread] | Current Thread | [Next in Thread] |