optimize Method

Performs an optimization on the model.

This is a two-step process:
  • First create the optimizer with the problem definition.
  • Second, instruct the optimizer to optimize the specified system to a desired accuracy.

Example

This is the optimize method for the FourBar class.
def optimize (self):

    # Define the cost functions in a list – there are 3 of these
    obj = [self.a2x, self.a2y, self.a2psi]

    # Define the weights for the cost functions in a list – there are 3 of these
wt  = [1,1,1]

# Define the list of responses consist of inequality constraints – there are 6 of these
ineq = [self.cons1, self.cons2, self.cons3, self.cons4, self.cons5, self.cons6]

    # Create the optimizer
    opt = Optimizer ( label           = "Optimize RMS2",  # Label
                      objective       = obj,              # Objectives
                      weights         = wt,               # Weights
                      type            = "KINEMATICS",     # Simulation Type
                      end             = 2,                # End Time
                      dtout           = 0.01,             # No. of steps
                      plot            = True,             # Display plots
                      ineqConstraints = ineq              # Inequality constraints
                    )
        
    # Now perform the optimization
    x = opt.optimize ()    
        
    # Return the result        
    return x

Example

This example shows how the simulate method can be passed to the optimizer.
def optimize (self):

    # Define the cost functions in a list – there are 3 of these
    obj = [self.a2x, self.a2y, self.a2psi]

    # Define the weights for the cost functions in a list – there are 3 of these
    wt  = [1,1,1]

    # Create the optimizer
    opt = Optimizer ( label     = "Optimize RMS2",  # Label
                      objective = obj,              # Objectives
                      weights   = wt,               # Weights
                      simMethod = self.simulate     # The simulation method
                      plot      = True,             # Display plots
                    )
        
    # Now perform the optimization
    x = opt.optimize (accuracy=1e-3)    
        
    # Return the result        
    return x