help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] HTML visualizer for GLPK glp_prob instances


From: Robbie Morrison
Subject: [Help-glpk] HTML visualizer for GLPK glp_prob instances
Date: Thu, 21 Aug 2008 21:40:37 +0200
User-agent: Thunderbird 1.5.0.14ubu (X11/20080306)

Hello GLPK API users, Andrew

A few days ago, I posted on the topic of visualizing
small-scale GLPK problem objects.  Here my follow up
posting as promised.

I recently finished and tested a C++ class called
'GlpkViz'.  Objects of this class can be used to
interrogate 'glp_prob' instances and output their
findings as HTML for subsequent viewing in a web
browser.  The 'GlpkViz' object will also open your
browser too if passed a suitable invocation string on
construction.  In many respects, the functionality
mirrors 'lpx_print_prob' and friends.  However, the
rendered HTML is easier to read.  In addition, missing
or suspect data is highlighted with an orange cell
border.

Example output is available from the links below.  In
the first case, the following MILP solver call given
below has been inserted immediately after the existing
LP solver call:

   glp_intopt(lp, NULL);

Here is the HTML output for 'sample.c' (GLPK 4.29 API
manual page 12) for a modified version of the original
problem with column two marked as integer-valued and
with the revised bounds [-inf, 2]:

 
http://www.iet.tu-berlin.de/morrison/glpkviz/pro-124047-glpk-tutorial-029459-01.html

And here is the output for 'plan.lp' (GLPK 4.29 API
manual page 137) using bounds instead of constraints
to restrain the variables:

 
http://www.iet.tu-berlin.de/morrison/glpkviz/pro-124047-plan_lp-siviz-029459-02.html

This example also says "MILP undefined" because the
MILP solver was not invoked.

As mentioned earlier, about 200 x 200 is about the
upper limit for usability.

I wrote this utility class because I never see my
optimization problems in simple form.  Unlike
'sample.c', my problems are created on-the-fly with
input from objects all over the place.  'GlpkViz' can
help me debug both my application code and, later on,
individual models.

Usage is a follows (assuming you want the HTML
displayed immediately, also best to open firefox in
advance):

  #include "glpkviz.h"        // GLPK problem instance visualizer
  int main()                  // compile as C++
  {
    GlpkViz viz("firefox");  // with browser invocation string
    glp_prob* prob;
    prob = glp_create_prob();
    viz(prob, "as created"); // view empty problem
    ..                       // GLPK problem building calls
    viz(prob, "as built");   // view as-built problem
    ..                       // GLPK solver calls
    viz(prob, "as solved");  // view solver-submitted problem
  }

If you want a single file build (rather than the normal
3-box method which requires linking to 'glpviz.o'),
then hash-include 'glpviz.cc' instead of 'glpviz.h':

  #include "glpkviz.cc"

The class synopsis is:

  GlpkViz
  (const std::string  browserCall);

  void
  GlpkViz::operator()
  (glp_prob*          problem,
   const std::string  comment         = "",
   const int          outputPrecision = 6,
   const bool         glpkRounding    = true);

'GlpkViz' could be useful for university teaching.
Indeed, I found experimenting with the 'sample.c'
problem quite revealing in terms of how GLPK exactly
views the world.

Moreover, if this class meets a general need, it could
be re-implemented in C along the lines, for instance:

  glp_html_prob(mip, "some comment", 4, false);

  where '4' is the output precision and
  'false' means do not temporarily
  employ GLPK close-to-zero rounding

I am happy to publish the code (any suggestions as to
where?).  Otherwise, email me directly for the current
tarball.  No additional libraries (Boost, for example)
or new language features (std::tr1::shared_ptr, for
example) are needed.  The license is GNU GPLv3.

Any comments, expressions of interest, or feedback
would be appreciated.

with best wishes
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
[from IMAP client]







reply via email to

[Prev in Thread] Current Thread [Next in Thread]