Changeset 5689


Ignore:
Timestamp:
04/20/12 12:47:08 (2 years ago)
Author:
dlwoodr
Message:

Added a little blurb to indicate how to access parameter values from a script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.doc/trunk/GettingStarted/current/scripts.txt

    r5662 r5689  
    315315---- 
    316316 
     317This code could be improved by checking to see if the variable is not indexed (i.e., the only index 
     318value is +None+), then the code could print the value without the word +None+ next to it. 
     319 
    317320==== All Variables from Workflow Callbacks ==== 
    318321 
     
    332335        for index in varobject: 
    333336            print "   ",index, varobject[index].value 
     337---- 
     338=== Accessing Parameter Values === 
     339 
     340Access to paramaters is completely analgous to access to variables. For example, here is a code 
     341snippet to print the name and value of every Parameter: 
     342 
     343---- 
     344from coopr.pyomo import Param 
     345for p in instance.active_components(Param): 
     346    print "Parameter",p 
     347    parmobject = getattr(instance, p) 
     348    for index in parmobject: 
     349        print "   ",index, parmobject[index].value 
    334350---- 
    335351 
Note: See TracChangeset for help on using the changeset viewer.