/* * The are no memory allocation in mlcp_direct, all necessary memory must be allocated by the user. * *options: * iparam[0] : (in) verbose. * dparam[0] : (in) a positive value, tolerane about the sign used by the path algo. * iparam[5] : (in) n0 number of possible configuration. * dparam[5] : (in) a positive value, tolerane about the sign. * dWork : working float zone size : n + m + n0*(n+m)*(n+m) . MUST BE ALLOCATED BY THE USER. * iWork : working int zone size : (n + m)*(n0+1) + nO*m. MUST BE ALLOCATED BY THE USER. * double *z : size n+m * double *w : size n+m * info : output. info == 0 if success */ void mlcp_direct_path(MixedLinearComplementarityProblem* problem, double *z, double *w, int *info, SolverOptions* options) { /*First, try direct solver*/ mlcp_direct(problem, z, w, info, options); if (*info) { /*solver direct failed, so run the path solver.*/ mlcp_path(problem, z, w, info, options); if (!(*info)) { /* for (i=0;i<problem->n+problem->m;i++){ */ /* printf("w[%d]=%f z[%d]=%f\t",i,w[i],i,z[i]); */ /* } */ mlcp_direct_addConfigFromWSolution(problem, w + sN); } } }
/* * The are no memory allocation in mlcp_direct, all necessary memory must be allocated by the user. * *options: * iparam[0] : (in) verbose. * dparam[0] : (in) a positive value, tolerane about the sign used by the enum algo. * iparam[5] : (in) n0 number of possible configuration. * dparam[5] : (in) a positive value, tolerane about the sign. * dWork : working float zone size : n + m + n0*(n+m)*(n+m) . MUST BE ALLOCATED BY THE USER. * iWork : working int zone size : (n + m)*(n0+1) + nO*m. MUST BE ALLOCATED BY THE USER. * double *z : size n+m * double *w : size n+m * info : output. info == 0 if success */ void mlcp_direct_path_enum(MixedLinearComplementarityProblem* problem, double *z, double *w, int *info, SolverOptions* options) { if (!siWorkPathEnum) { *info = 1; printf("MLCP_DIRECT_PATH_ENUM error, call a non initialised method!!!!!!!!!!!!!!!!!!!!!\n"); return; } /*First, try direct solver*/ options->dWork = sdWorkDirect; options->iWork = siWorkDirect; mlcp_direct(problem, z, w, info, options); if (*info) { options->dWork = sdWorkPathEnum; options->iWork = siWorkPathEnum; /*solver direct failed, so run the enum solver.*/ mlcp_path_enum(problem, z, w, info, options); if (!(*info)) { mlcp_direct_addConfigFromWSolution(problem, w + sN); } } }