-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to solve that will dump the solution. #42
Conversation
I like the idea of dumping results and the instance to the terminal for development. |
I have mixed feelings about the first comment. I agree on the need to streamline the process of completely comparing results from two runs, and instance.pprint() is adequate, but not optimized for that review. I almost always use it in conjunction with diff to highlight the changes relative to a reference model. Yes, results.write only gives summary info about the solution, not detailed info on decision variable values. In the past, I've used instance.pprint() rather than instance.display(). I just compared the two and pprint() provides more details than display(). display() shows variables, the objective function value, and constraints. pprint() shows all that plus sets, parameters, expressions, BuildChecks (along with equations for each), as well as a comprehensive list of model components. For brevity display() is better, but for a comprehensive check, pprint() wins out. I actually don't like it dumping to the screen, and would prefer all of that output to go to a log file. I didn't have time to figure out how to do that cleanly, but I wanted to add a partial solution that was adequate. |
Maybe it would be best to change Then if people want to run
Adding this module's name to Alternatively, we could write a standard reporting module, On a partially related note: It would be nice if this function and Also, eventually I'd like to have a general-purpose tabular reporting system, where users can call a helper function to register any expressions that they want reported, along with the indexes and (optional) filename to use for them. Then the reporting module would create a single output file for each specified filename and/or indexing set, and would automatically create a column for each expression that's been assigned to that file (there would probably also be some standard expressions registered automatically). I know tables like this aren't great for saving results in a database, but lately I find it easiest to pull data directly from the output files into Excel or Pandas, and this works very well. |
… of small example problems a useful tool during development.
… verbose dump to most of the examples and updated their output files. A full dump of prior example solutions could be useful for debugging. I didn't dump the 3zone toy results because that dump files was 432K, and I didn't want to clog up the repo.
20a2183
to
2bba511
Compare
I like the features you are describing Matthias. Maybe we can paste those into a new issue so the idea will stick around after this pull request is closed. I moved that functionality into a custom export module and updated most of the examples to include a full dump. Any comments on this version? |
A couple of questions about the custom export modules: At one point I abandoned Would it be better to exclude the dump files from the git repository? I usually omit outputs from the repository to save space (and they're making it a little hard to make sense of this commit). I would also recommend moving the results dump code from solve.main() to solve.post_solve(), if it's not moved into a completely separate reporting module. |
I just copied the general reporting suggestions into a couple of new issues. So we can close this pull request once the dumping code is finalized without fear of losing them. |
I think I prefer the alternative of having a single dumping module in the
Also, I would include an option to have the dump printed additionally on the terminal if wanted. This could be achieved with the Logging class. This feature would be useful when working with toy inputs sets while developing, for quick eye inspection. As for your last commit, I agree that the dump files could be kept out of the repository, so we don't experience difficulties reading through the commits (we would have hundreds of changed lines every time we modified an example or added a new one). If we finally go with the alternative of having those 2 modules ( Regarding the last issue, I noticed the same conflict between save_results() and post_solve(). Would there be any reason to require passing the results object to the output processing function? When writing output files, I have just been querying the instance itself with the Besides that, I think that the |
This sounds like a good plan. We could do this with something like If we assume this output should always go to I think I renamed the callback from |
I will work on standardizing the I also want to add an |
I'm ok with migrating from save_results() to post_solve(). I like the clarity of the former name, but see how post_solve() can sound more like a catch-all. At some point, it could be useful to add two separate layers for post-processing and exporting results (numerical data, summaries, figures, etc). If you are working iteratively, you may want to do post-processing between runs to nab some key summary values, but only export results periodically or after final completion. At the moment, I don't have a good use case for splitting these into separate functions, so I'm fine with a wait-and-see approach to adding complexity. Alternately, if it's easier to clean the codebase by keeping post-processing separate from export (i.e. saving numeric and graphical files in a results directory), I'm fine with that too. Benjamin, are you volunteering for some of the work on that? If so, thank you! :) I'll cut the dump files out of the repo. I'd be fine with cutting all of the results except the objective function value if y'all want, although I would put that in a separate commit. Regarding the interface, I'm cool with merging into one dump module with a command line option. I'd rather have the output of instance.pprint separate from instance.display because display is a subset of pprint, so having 1-3 in additive order isn't so nice for me. I also don't see anyone caring much about the results.write() output by itself. We could do a --dump-level=[1-2], where 1 is instance.display() and 2 is instance.pprint() I'll post an implementation of that when I get a chance, hopefully later tonight. |
…le. Command line options control the level of detail and whether the output is also sent to stdout.
I like it, seems good to go in my opinion. As a side note: the copyright header still lists the year 2015. Shouldn't that be changed to 2016 in all scripts? I'm not sure if that is how licenses work. |
…le. Command line options control the level of detail and whether the output is also sent to stdout. Pull request #42
OK, I just pushed the simple switch_mod.export.dump solution. Thanks for the reviews and conversation :) Benjamin, I'm not sure about the copyright header .. I've seen people list multiple years or a range of years there, like "Copyright 2015-2016". If we could do "Copyright 2015-present", that would save having to redo it later, but I don't if that's legit. |
Add an option to solve that will dump the solution. I find inspection of small example problems a useful tool during development.