Changeset 3094


Ignore:
Timestamp:
Oct 13, 2010 10:17:29 PM (10 years ago)
Author:
wehart
Message:

Adding a --help-solvers option to pyomo.

Location:
coopr.pyomo/trunk/coopr/pyomo/scripting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/scripting/pyomo.py

    r3081 r3094  
    200200        dest='help_components',
    201201        default=False)
     202    otherOpts.add_option('--help-solvers',
     203        help='Print information about the solvers that are available',
     204        action='store_true',
     205        dest='help_solvers',
     206        default=False)
    202207    otherOpts.add_option('-i', '--interactive',
    203208        help='After executing Pyomo, launch an interactive Python shell.  If IPython is installed, this shell is an IPython shell.',
     
    256261    if options.help_components:
    257262        util.print_components(options)
     263        return Container()
     264    if options.help_solvers:
     265        util.print_solver_help(options)
    258266        return Container()
    259267    if not util.setup_environment(options, args):
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r3081 r3094  
    2222except ImportError:
    2323    pstats_available=False
     24import textwrap
    2425import gc
    2526from coopr.pyomo import *
     
    6667        print " "+pyomo_sets[i][0]
    6768        print "    "+pyomo_sets[i][1]
     69
     70#
     71# Print information about the solvers that are available
     72#
     73def print_solver_help(options):
     74    print "The following solvers are are currently supported:"
     75    solver_list = SolverFactory.services()
     76    solver_list = sorted( filter(lambda x: '_' != x[0], solver_list) )
     77    n = max(map(len, solver_list))
     78    wrapper = textwrap.TextWrapper(subsequent_indent=' '*(n+9))
     79    for s in solver_list:
     80        format = '    %-'+str(n)+'s  %s'
     81        print wrapper.fill(format % (s , SolverFactory.doc(s)))
     82    print 'The default solver is glpk.'
     83    print ""
     84    wrapper = textwrap.TextWrapper(replace_whitespace=False)
     85    print wrapper.fill('Subsolver options can be specified by with the solver name followed by colon and then the subsolver.  For example, the following specifies that the asl solver will be used:')
     86    print '   --asl:PICO'
     87    print wrapper.fill('This indicates that the asl solver will launch the PICO executable to perform optimization. Currently, no other solver supports this syntax.')
     88
    6889
    6990#
Note: See TracChangeset for help on using the changeset viewer.