#include "csocp.h" #include "data.h" #include #include #include int main(int argc, char *argv[]) { c_int nstatus = 0; c_real *x = NULL; csocp_prob *prob = NULL; #ifndef LUOYC printf("length = %d\n", sizeof(double *)); #endif /* Allocate memory for primal solution */ x = (c_real *)malloc(n * sizeof(c_real)); /* Create CSOCP problem */ CSOCP_create(&prob); /* Load CSOCP problem */ CSOCP_loadsocp(prob, n, m, p, l, ncones, q, Gpr, Gjc, Gir, Apr, Ajc, Air, c, h, b); /* Solve problem */ CSOCP_solve(prob); /* Get solution status */ nstatus = CSOCP_getintattr(prob, CSOCP_INTATTR_STATUS); printf("\nSolution status: %d\n", nstatus); if (nstatus == CSOCP_OPTIMAL) { CSOCP_getsolution(prob, x, NULL, NULL, NULL); printf("\nVariable solutions: \n"); int i = 0; for (i = 0; i < n; ++i) { if (fabs(x[i]) > 1e-7) { printf(" x[%d] = %+.9f\n", i, x[i]); } } } else { printf("\nNo solution.\n"); } if (x != NULL) { free(x); } CSOCP_free(&prob); return 0; }