Ejemplo n.º 1
0
Archivo: demo.c Proyecto: zhangrj7/scs
int main(int argc, char **argv) {
	FILE * fp;
	Cone * k;
	Data * d;
	Work * w;
	Sol * sol;
	Info info = { 0 };
	scs_int i;

	if (openFile(argc, argv, 1, DEMO_PATH, &fp) < 0)
		return -1;

	k = scs_calloc(1, sizeof(Cone));
	d = scs_calloc(1, sizeof(Data));
	sol = scs_calloc(1, sizeof(Sol));
	if (readInData(fp, d, k) == -1) {
		printf("Error reading in data, aborting.\n");
		return -1;
	}
	fclose(fp);
	scs_printf("solve once using scs\n");
	scs(d, k, sol, &info);

	if (TEST_WARM_START) {
		scs_printf("solve %i times with warm-start and (if applicable) factorization caching.\n", NUM_TRIALS);
		/* warm starts stored in Sol */
		w = scs_init(d, k, &info);
		if (w) {
			for (i = 0; i < NUM_TRIALS; i++) {
				/* perturb b and c */
				perturbVector(d->b, d->m);
				perturbVector(d->c, d->n);
				d->stgs->warm_start = 1;
				d->stgs->cg_rate = 4;
				scs_solve(w, d, k, sol, &info);
				d->stgs->warm_start = 0;
				d->stgs->cg_rate = 2;
				scs_solve(w, d, k, sol, &info);
			}
		}
		scs_printf("finished\n");
		scs_finish(w);
	}

	freeData(d, k);
	freeSol(sol);
	return 0;
}
Ejemplo n.º 2
0
Archivo: scs.c Proyecto: tkelman/scs
/* this just calls scs_init, scs_solve, and scs_finish */
idxint scs(Data * d, Cone * k, Sol * sol, Info * info) {
#if ( defined _WIN32 || defined _WIN64 ) && !defined MATLAB_MEX_FILE && !defined PYTHON
	/* sets width of exponent for floating point numbers to 2 instead of 3 */
	unsigned int old_output_format = _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
	Work * w = scs_init(d, k, info);
#ifdef EXTRAVERBOSE
	scs_printf("size of idxint = %lu, size of pfloat = %lu\n", sizeof(idxint), sizeof(pfloat));
#endif
	if (!w) {
		return failureDefaultReturn(d, NULL, sol, info, "could not initialize work");
	}
	scs_solve(w, d, k, sol, info);
	scs_finish(d, w);
	return info->statusVal;
}
Ejemplo n.º 3
0
/**
 * avp_init:
 *
 * (Re)Initializes the avp library.
 *
 **/
extern void avp_init(void) {

	if (avp_strings) destroy_scs_collection(avp_strings);
	avp_strings = scs_init();

}