Example for Second Order Cone Programming. Similar to Matlab example provided by M. S. Lobo et al. from http://www.stanford.edu/~boyd/old_software/socp/@verbatim Minimize x + y subject to (x+1)^2 + (y-1)^2 <= 1.
- Author
- esquivel 05/2012
#include <bias_config.h>
#include <MathAlgo/SOCP.hh>
#include <Base/Math/Random.hh>
using namespace BIAS;
using namespace std;
int main(int args, char **arg)
{
const int m = 2;
const int n = 2;
double d;
f[0] = f[1] = 1;
A[0][0] = A[1][1] = 1;
b[0] = 1;
b[1] = -1;
c[0] = c[1] = 0;
d = 1;
double w;
x[0] = -0.5;
x[1] = 1;
z[0] = 1;
z[1] = 1;
w = 4;
int res = socp.
Compute(m, n, f, A, b, c, d, x, z, w);
cout << "Return code of SOCP solver = " << res << endl;
cout << "Primal problem : " << endl;
cout << " Final primal solution x = " << x << endl;
cout << " Constraint evaluation for solution x : " << endl
cout << "Dual problem : " << endl;
cout << " Final dual solution z = " << z << ", w = " << w << endl;
cout << " Target value of -(b'z + dw) = " << -(b.ScalarProduct(z) + d*w) << endl;
cout << " Constraint evaluation for solution z, w : " << endl
<< " = f = " << f << endl;
cout <<
" |z| = " << z.
NormL2() <<
" <= w = " << w << endl;
return 0;
}