Changeset 2190


Ignore:
Timestamp:
Jan 27, 2010 10:27:38 PM (10 years ago)
Author:
wehart
Message:

Adding a plugin to manage parsing of IO to support interaction with
Dakota.

Location:
coopr.colin/trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.colin/trunk/coopr/colin/core/__init__.py

    r2188 r2190  
    1111from point import *
    1212import colin_xml_io
     13import dakota_text_io
    1314from problem import *
    1415import solver
     16
  • coopr.colin/trunk/coopr/colin/core/colin_xml_io.py

    r2188 r2190  
    1616from problem_io import *
    1717import xml.dom.minidom
    18 from pyutilib.misc import get_xml_text
     18from pyutilib.misc import get_xml_text, tostr
    1919
    2020
     
    7070            elt = doc.createElement(str(key))
    7171            root.appendChild(elt)
    72             text_elt = doc.createTextNode( response[key] )
     72            if isinstance(response[key], basestring):
     73                text_elt = doc.createTextNode( response[key] )
     74            elif type(response[key]) in [int,long,float]:
     75                text_elt = doc.createTextNode( str(response[key]) )
     76            else:
     77                text_elt = doc.createTextNode( tostr(response[key]) )
    7378            elt.appendChild(text_elt)
    7479        return doc
  • coopr.colin/trunk/coopr/colin/core/problem.py

    r2188 r2190  
    2121import sys
    2222from pyutilib.enum import Enum
    23 from pyutilib.misc import tostr
    2423from problem_io import IOptProblemIO
    2524from pyutilib.plugin.core import *
     
    9291        Compute a list of function values.
    9392        """
    94         return []
     93        val = self.function_value(point)
     94        if val is None:
     95            return []
     96        else:
     97            return [val]
    9598
    9699    def gradient(self, point):
     
    122125            #
    123126            elif key == "FunctionValue":
    124                response[key] = str(self.function_value(point))
     127               response[key] = self.function_value(point)
    125128            elif key == "FunctionValues":
    126                response[key] = tostr(self.function_values(point))
     129               response[key] = self.function_values(point)
    127130            elif key == "Gradient":
    128                response[key] = tostr(self.gradient(point))
     131               response[key] = self.gradient(point)
    129132            elif key == "NonlinearConstraintValues":
    130                response[key] = tostr(self.nonlinear_constraint_values(point))
     133               response[key] = self.nonlinear_constraint_values(point)
    131134            elif key == "Jacobian":
    132                response[key] = tostr(self.jacobian(point))
     135               response[key] = self.jacobian(point)
    133136            #
    134137        return response
Note: See TracChangeset for help on using the changeset viewer.