Esempio n. 1
0
def getMin(*args):
    """Solves an unconstrained optimization problem
    Basic solve: getMin(X,msg,fns,state) 
    Solve with a state manipulator: getMin(X,msg,fns,state,smanip)
    """

    # Check the number of arguments
    if len(args) != 4 and len(args) != 5:
        raise Exception(
            "The getMin function requires either 4 or 5 arguments, "
            "but %d given." % len(args))

    # Extract the arguments
    X = args[0]
    msg = args[1]
    fns = args[2]
    state = args[3]
    smanip = Optizelle.StateManipulator() if len(args) == 4 else args[4]

    # Check the arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.Unconstrained.Functions.checkT("fns", fns)
    Optizelle.Unconstrained.State.checkT("state", state)
    Optizelle.checkStateManipulator("smanip", smanip)

    # Call the optimization
    Optizelle.Utility.UnconstrainedAlgorithmsGetMin(X, msg, fns, state, smanip)
Esempio n. 2
0
def getMin(*args):
    """Solves an equality constrained optimization problem
    Basic solve: getMin(X,Y,msg,fns,state) 
    Solve with a state manipulator: getMin(X,Y,msg,fns,state,smanip)
    """

    # Check the number of arguments
    if len(args)!=5 and len(args)!=6:
        raise Exception("The getMin function requires either 5 or 6 arguments, "
            "but %d given." % len(args))

    # Extract the arguments
    X=args[0]
    Y=args[1]
    msg=args[2]
    fns = args[3] 
    state = args[4] 
    smanip = Optizelle.StateManipulator() if len(args)==5 else args[5]

    # Check the arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkVectorSpace("Y",Y)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.EqualityConstrained.Functions.checkT("fns",fns)
    Optizelle.EqualityConstrained.State.checkT("state",state)
    Optizelle.checkStateManipulator("smanip",smanip)

    # Call the optimization
    Optizelle.Utility.EqualityConstrainedAlgorithmsGetMin(
        X,Y,msg,fns,state,smanip)
Esempio n. 3
0
def read_restart(X, msg, fname, x, state):
    """Reads a json restart file"""

    # Check our arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.checkString("fname", fname)
    Optizelle.Unconstrained.State.checkT("state", state)

    # Do the read
    Optizelle.Utility.UnconstrainedRestartReadRestart(X, msg, fname, x, state)
Esempio n. 4
0
def read(X, msg, fname, state):
    """Read parameters from file"""

    # Check our arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.checkString("fname", fname)
    Optizelle.Unconstrained.State.checkT("state", state)

    # Do the read
    Optizelle.Utility.UnconstrainedStateReadJson(X, msg, fname, state)
Esempio n. 5
0
def write_restart(X, msg, fname, state):
    """Writes a json restart file"""

    # Check our arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.checkString("fname", fname)
    Optizelle.Unconstrained.State.checkT("state", state)

    # Do the write
    Optizelle.Utility.UnconstrainedRestartWriteRestart(X, msg, fname, state)
Esempio n. 6
0
def read_restart(X,msg,fname,x,state):
    """Reads a json restart file"""
    
    # Check our arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.checkString("fname",fname)
    Optizelle.Unconstrained.State.checkT("state",state)

    # Do the read 
    Optizelle.Utility.UnconstrainedRestartReadRestart(X,msg,fname,x,state)
Esempio n. 7
0
def write_restart(X,msg,fname,state):
    """Writes a json restart file"""
    
    # Check our arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.checkString("fname",fname)
    Optizelle.Unconstrained.State.checkT("state",state)

    # Do the write
    Optizelle.Utility.UnconstrainedRestartWriteRestart(X,msg,fname,state)
Esempio n. 8
0
def read(X,msg,fname,state):
    """Read parameters from file"""
        
    # Check our arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.checkString("fname",fname)
    Optizelle.Unconstrained.State.checkT("state",state)

    # Do the read
    Optizelle.Utility.UnconstrainedStateReadJson(X,msg,fname,state)
Esempio n. 9
0
    def __init__(self, X, msg, x):
        """Constructor"""

        # Check our arguments
        Optizelle.checkVectorSpace("X", X)
        Optizelle.checkMessaging("msg", msg)

        # Allocate memory for our vectors
        allocateVectors(self, X, x)

        # Create the state
        Optizelle.Utility.UnconstrainedStateCreate(self, X, msg, x)
Esempio n. 10
0
    def __init__(self,X,msg,x):
        """Constructor"""

        # Check our arguments
        Optizelle.checkVectorSpace("X",X)
        Optizelle.checkMessaging("msg",msg)

        # Allocate memory for our vectors
        allocateVectors(self,X,x)

        # Create the state
        Optizelle.Utility.UnconstrainedStateCreate(self,X,msg,x)
Esempio n. 11
0
def release(X,msg,state,xs,reals,nats,params):
    """Release the data into structures controlled by the user"""

    # Check the arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.Unconstrained.State.checkT("state",state)

    # Release the information from the state
    Optizelle.Utility.UnconstrainedRestartRelease(
        X,msg,state,xs,reals,nats,params)

    # Return nothing.  We've modified the passed in lists.
    return None 
Esempio n. 12
0
def release(X, msg, state, xs, reals, nats, params):
    """Release the data into structures controlled by the user"""

    # Check the arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.Unconstrained.State.checkT("state", state)

    # Release the information from the state
    Optizelle.Utility.UnconstrainedRestartRelease(X, msg, state, xs, reals,
                                                  nats, params)

    # Return nothing.  We've modified the passed in lists.
    return None
Esempio n. 13
0
    def __init__(self,X,Z,msg,x,z):
        """Constructor"""

        # Check our arguments
        Optizelle.checkVectorSpace("X",X)
        Optizelle.checkEuclidean("Z",Z)
        Optizelle.checkMessaging("msg",msg)
        
        # Allocate memory for our vectors
        Optizelle.Unconstrained.State.allocateVectors(self,X,x)
        allocateVectors(self,X,Z,x,z)

        # Create the state
        Optizelle.Utility.InequalityConstrainedStateCreate(self,X,Z,msg,x,z)
Esempio n. 14
0
def capture(X,msg,state,xs,reals,nats,params):
    """Capture data from structures controlled by the user."""

    # Check the arguments
    Optizelle.checkVectorSpace("X",X)
    Optizelle.checkMessaging("msg",msg)
    Optizelle.Unconstrained.State.checkT("state",state)
    Optizelle.checkVectors('xs',xs)
    Optizelle.checkReals('reals',reals)
    Optizelle.checkNaturals('nats',nats)
    Optizelle.checkParams('params',params)

    # Capture the restart information
    Optizelle.Utility.UnconstrainedRestartCapture(
        X,msg,state,xs,reals,nats,params)

    # Return nothing.  The state has been modified.
    return None 
Esempio n. 15
0
def capture(X, msg, state, xs, reals, nats, params):
    """Capture data from structures controlled by the user."""

    # Check the arguments
    Optizelle.checkVectorSpace("X", X)
    Optizelle.checkMessaging("msg", msg)
    Optizelle.Unconstrained.State.checkT("state", state)
    Optizelle.checkVectors('xs', xs)
    Optizelle.checkReals('reals', reals)
    Optizelle.checkNaturals('nats', nats)
    Optizelle.checkParams('params', params)

    # Capture the restart information
    Optizelle.Utility.UnconstrainedRestartCapture(X, msg, state, xs, reals,
                                                  nats, params)

    # Return nothing.  The state has been modified.
    return None