// Assume by the time this constructor is called, the number of parameters and constraints has been finalized
InteriorPointOptimizer::InteriorPointOptimizer( const OptimizerSystem& sys )
        : OptimizerRep( sys ) {

        int n = sys.getNumParameters();
        int m = sys.getNumConstraints();

        if( n < 1 ) {
            const char* where = " InteriorPointOptimizer Initialization";
            const char* szName = "dimension";
            SimTK_THROW5(SimTK::Exception::ValueOutOfRange, szName, 1, n, INT_MAX, where); 
        }

        // Initialize arrays to store multipliers -- will be used for warm starts
        mult_x_L = new Number[n];
        mult_x_U = new Number[n];
        mult_g = new Number[m];
        for(int i=0;i<n;i++) mult_x_L[i] = mult_x_U[i] = 0;
        for(int i=0;i<m;i++) mult_g[i] = 0;

        g_L = new Number[m];
        g_U = new Number[m];
        /* set the bounds on the equality constraint functions */
        for(int i=0;i<sys.getNumEqualityConstraints();i++){
            g_U[i] = g_L[i] = 0.0;
        }
        /* set the bounds on the inequality constraint functions */
        for(int i=sys.getNumEqualityConstraints();i<m;i++){
            g_U[i] = SimTK::Real(POSITIVE_INF);
            g_L[i] = 0.0;
        }

        firstOptimization = true;
    } 
Пример #2
0
//_____________________________________________________________________________
CFSQPOptimizer::CFSQPOptimizer(const OptimizerSystem& sys)
    : OptimizerRep(sys)
{
    bindToCFSQPLibrary();

    _infinity = 1.0e10;
    _mode = 100;
    _epseqn = 1.0e-8;
    _inform = 0;
    _udelta = 0.0;

    int nx = sys.getNumParameters();

    // NEW MAX ITERATIONS
    maxIterations = 4 * nx;

    // SQP STUFF- NOT CURRENTLY SUPPORTED
    int i;
    _ncsrl = 0;
    _ncsrn = 0;
    _nfsr = 0;
    int lenmesh = _nfsr+_ncsrn+_ncsrl;  if(lenmesh<1) lenmesh=1;
    _mesh = new int[lenmesh];
    for(i=0;i<lenmesh;i++)  _mesh[i] = 0;

    // PERFORMANCE
    int lenp = 1 - _nfsr; // _target->getNumContacts() - _nfsr;
    for(int i=0;i<_nfsr;i++)  lenp += _mesh[i];
    if(lenp<1) lenp = 1;
    _p = new double[lenp];

    // CONSTRAINTS
    int lenc = sys.getNumConstraints() - _ncsrl - _ncsrn;
    for(int i=0;i<_ncsrn;i++)  lenc += _mesh[i+_nfsr];
    for(int i=0;i<_ncsrl;i++)  lenc += _mesh[i+_nfsr+_ncsrn];
    if(lenc<1) lenc = 1;
    _c = new double[lenc];

    // LAGRANGE MULTIPLIERS
    _lambda = new double[nx+lenp+lenc];
}
Пример #3
0
LBFGSBOptimizer::LBFGSBOptimizer( const OptimizerSystem& sys )
:   OptimizerRep( sys ),
    factr( 1.0e7) {
    int n,i;

    n = sys.getNumParameters();

    if( n < 1 ) {
        const char* where = "Optimizer Initialization";
        const char* szName = "dimension";
        SimTK_THROW5(SimTK::Exception::ValueOutOfRange, szName, 1,  n, INT_MAX, where);
    }

    /* We don't yet know what kinds of bounds we'll have so set the bounds
       descriptor nbd to an illegal value. */
    nbd = new int[n];
    for(i=0;i<n;i++)
        nbd[i] = -1;
}