本文整理汇总了C++中OoqpVector::randomize方法的典型用法代码示例。如果您正苦于以下问题:C++ OoqpVector::randomize方法的具体用法?C++ OoqpVector::randomize怎么用?C++ OoqpVector::randomize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OoqpVector
的用法示例。
在下文中一共展示了OoqpVector::randomize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: datarandom
void QpGenData::datarandom( OoqpVector & x, OoqpVector & y,
OoqpVector & z, OoqpVector & s )
{
double drand( double * );
double ix = 3074.20374;
OoqpVectorHandle xdual(la->newVector( nx ));
this->randomlyChooseBoundedVariables( x, *xdual,
*blx, *ixlow, *bux, *ixupp,
&ix, .25, .25, .25 );
{
// ofstream x_vec( "x" );
// x->writeToStream( x_vec );
// ofstream eta_vec( "xdual" );
// eta_vec.precision(16);
// xdual->writeToStream( eta_vec );
// ofstream blx_vec( "blx" );
// blx->writeToStream( blx_vec );
// ofstream bux_vec( "bux" );
// bux->writeToStream( bux_vec );
}
OoqpVectorHandle sprime(la->newVector( mz ));
this->randomlyChooseBoundedVariables( *sprime, z,
*bl, *iclow, *bu, *icupp,
&ix, .25, .25, .5 );
{
// ofstream z_vec( "z" );
// z_vec << z << endl;
}
{
Q->randomizePSD( &ix );
// ofstream Q_mat( "Q" );
// Q_mat << Q << endl;
}
{
A->randomize( -10.0, 10.0, &ix );
// ofstream A_mat( "A" );
// A_mat << A << endl;
}
{
C->randomize( -10.0, 10.0, &ix );
// ofstream C_mat( "C" );
// C_mat << C << endl;
}
y.randomize( -10.0, 10.0, &ix );
{
// ofstream y_vec( "y" );
// y_vec << y << endl;
}
// g = - Q x + A\T y + C\T z + xdual
g->copyFrom( *xdual );
Q->mult( 1.0, *g, -1.0, x );
A->transMult( 1.0, *g, 1.0, y );
C->transMult( 1.0, *g, 1.0, z );
// bA = A x
A->mult( 0.0, *bA, 1.0, x );
{
// ofstream bA_vec( "bA" );
// bA_vec << bA << endl;
}
// Have a randomly generated sprime.
// C x - s = 0. Let q + sprime = s, i.e. q = s - sprime.
// Compute s and temporarily store in q
C->mult( 0.0, s, 1.0, x );
// Now compute the real q = s - sprime
OoqpVectorHandle q(la->newVector( mz ));
q->copyFrom( s );
q->axpy( -1.0, *sprime );
// Adjust bl and bu appropriately
bl->axpy( 1.0, *q );
bu->axpy( 1.0, *q );
bl->selectNonZeros( *iclow );
bu->selectNonZeros( *icupp );
{
// ofstream bl_vec( "bl" );
// bl_vec << bl << endl;
// ofstream bu_vec( "bu" );
// bu_vec << bu << endl;
}
}