printResults Method

Prints the final optimization results to your specifications.

Example

This is the printResultsmethod for the FourBar class.
def printResults (self):

    m       = self.mbsModel

    # The exact answer to the optimization problem
    ax      = 0
    ay      = 0
    bx      = 40
    by      = 200
    cx      = 360
    cy      = 600
    dx      = 400
    dy      = 0

    # The exact answer stored as strings
    sax     = "{:>+8.2f}".format(ax)
    say     = "{:>+8.2f}".format(ay)
    sbx     = "{:>+8.2f}".format(bx)
    sby     = "{:>+8.2f}".format(by)
    scx     = "{:>+8.2f}".format(cx)
    scy     = "{:>+8.2f}".format(cy)
    sdx     = "{:>+8.2f}".format(dx)
    sdy     = "{:>+8.2f}".format(dy)

    # The optimized value of the design variables
    axo     = float(m.ax.b)
    ayo     = float(m.ay.b)
    bxo     = float(m.bx.b)
    byo     = float(m.by.b)
    cxo     = float(m.cx.b)
    cyo     = float(m.cy.b)
    dxo     = float(m.dx.b)
    dyo     = float(m.dy.b)
    
    # The optimized values saved as strings
    saxo    = "{:>+8.2f}".format(axo)
    sayo    = "{:>+8.2f}".format(ayo)
    sbxo    = "{:>+8.2f}".format(bxo)
    sbyo    = "{:>+8.2f}".format(byo)
    scxo    = "{:>+8.2f}".format(cxo)
    scyo    = "{:>+8.2f}".format(cyo)
    sdxo    = "{:>+8.2f}".format(dxo)
    sdyo    = "{:>+8.2f}".format(dyo)

    # The difference between the exact and computed values saved as strings
    daxo    = "{:>+8.2f}".format(ax-axo)
    dayo    = "{:>+8.2f}".format(ay-ayo)
    dbxo    = "{:>+8.2f}".format(bx-bxo)
    dbyo    = "{:>+8.2f}".format(by-byo)
    dcxo    = "{:>+8.2f}".format(cx-cxo)
    dcyo    = "{:>+8.2f}".format(cy-cyo)
    ddxo    = "{:>+8.2f}".format(dx-dxo)
    ddyo    = "{:>+8.2f}".format(dy-dyo)
    
    # The message to be written to the screen
    msg = """\

Optimization Results Summary:
-----------------------------

  Point        Actual             Obtained               Deviation
  -----      ----------     -------------------      -------------------
  A          (  0,   0)     ({}, {})     ({}, {})
  B          ( 40, 200)     ({}, {})     ({}, {})
  C          (360, 600)     ({}, {})     ({}, {})
  D          (400,   0)     ({}, {})     ({}, {})
""".format(saxo, sayo, daxo, dayo, sbxo, sbyo, dbxo, dbyo, scxo, scyo, dcxo, dcyo, sdxo, 
           sdyo, ddxo, ddyo)

    print msg
    return