int linearComplementarity_newFromFilename(LinearComplementarityProblem* problem, char* filename) { int info = 0; FILE * file = fopen(filename, "r"); info = linearComplementarity_newFromFile(problem, file); fclose(file); return info; }
int lcp_test_function_SBM(FILE * f, int solverId) { int i, info = 0 ; LinearComplementarityProblem* problem = (LinearComplementarityProblem *)malloc(sizeof(LinearComplementarityProblem)); info = linearComplementarity_newFromFile(problem, f); FILE * foutput = fopen("./lcp_mmc.verif", "w"); info = linearComplementarity_printInFile(problem, foutput); NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; SolverOptions * options = (SolverOptions *)malloc(sizeof(SolverOptions)); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_NSGS_SBM); set_SolverOptions(options->internalSolvers, solverId); #ifdef HAVE_GAMS_C_API if (solverId == SICONOS_LCP_GAMS) { // no testing for now deleteSolverOptions(options); free(options); freeLinearComplementarityProblem(problem); fclose(foutput); return 0; /* SN_GAMSparams* GP = (SN_GAMSparams*)options->internalSolvers->solverParameters; assert(GP); GP->model_dir = GAMS_MODELS_SOURCE_DIR;*/ } #endif double * z = (double *)calloc(problem->size, sizeof(double)); double * w = (double *)calloc(problem->size, sizeof(double)); info = linearComplementarity_driver(problem, z , w, options, &global_options); for (i = 0 ; i < problem->size ; i++) { printf("z[%i] = %12.8e\t,w[%i] = %12.8e\n", i, z[i], i, w[i]); } if (!info) { printf("test succeeded err=%e \n", options->dparam[1]); } else { printf("test unsuccessful err =%e \n", options->dparam[1]); } free(z); free(w); // info = linearComplementarity_deleteDefaultSolverOptions(&options,solvername); deleteSolverOptions(options); free(options); freeLinearComplementarityProblem(problem); fclose(foutput); return info; }
int main(void) { printf("\n Start of test on Default SolverOptions\n"); int info = 0 ; SolverOptions * options = (SolverOptions *)malloc(sizeof(SolverOptions)); FILE * finput = fopen("./data/lcp_mmc.dat", "r"); LinearComplementarityProblem* problem = (LinearComplementarityProblem *)malloc(sizeof(LinearComplementarityProblem)); info = linearComplementarity_newFromFile(problem, finput); fclose(finput); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_NSGS_SBM); assert(options->internalSolvers); solver_options_set(options->internalSolvers, SICONOS_LCP_LEMKE); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_PGS); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_RPGS); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_QP); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_NSQP); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_CPG); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_PSOR); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_LATIN); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_LATIN_W); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_LEMKE); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_PATH); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_ENUM); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_NEWTONMIN); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_AVI_CAOFERRIS); solver_options_print(options); solver_options_delete(options); info = linearComplementarity_setDefaultSolverOptions(problem, options, SICONOS_LCP_PIVOT); solver_options_print(options); solver_options_delete(options); freeLinearComplementarityProblem(problem); free(options); printf("\n End of test on Default SolverOptions\n"); return info; }
int lcp_test_function(FILE * f, int solverId, char* filename) { int i, info = 0 ; LinearComplementarityProblem* problem = (LinearComplementarityProblem *)malloc(sizeof(LinearComplementarityProblem)); info = linearComplementarity_newFromFile(problem, f); FILE * foutput = fopen("./lcp_mmc.verif", "w"); info = linearComplementarity_printInFile(problem, foutput); fclose(foutput); NumericsOptions global_options; setDefaultNumericsOptions(&global_options); global_options.verboseMode = 1; SolverOptions options; set_SolverOptions(&options, solverId); #ifdef HAVE_GAMS_C_API if (solverId == SICONOS_LCP_GAMS) { SN_GAMSparams* GP = (SN_GAMSparams*)options.solverParameters; assert(GP); GP->model_dir = GAMS_MODELS_SOURCE_DIR; assert(filename); GP->filename = filename; } #endif double * z = (double *)calloc(problem->size, sizeof(double)); double * w = (double *)calloc(problem->size, sizeof(double)); info = linearComplementarity_driver(problem, z , w, &options, &global_options); for (i = 0 ; i < problem->size ; i++) { printf("z[%i] = %12.8e\t,w[%i] = %12.8e\n", i, z[i], i, w[i]); } if (!info) { printf("test succeeded err = %e \n", options.dparam[1]); } else { printf("test unsuccessful err =%e \n", options.dparam[1]); } free(z); free(w); deleteSolverOptions(&options); if (solverId == SICONOS_LCP_GAMS) { free(options.solverParameters); options.solverParameters = NULL; } freeLinearComplementarityProblem(problem); printf("End of test.\n"); return info; }