/******************************************************** Xpress Optimizer Example Problems ================================= file foliomatenumsol.c `````````````````````` Using the MIP solution enumerator with a MIP problem input from a matrix file. (c) 2009 Fair Isaac Corporation author: D.Nielsen, S.Heipcke, July 2009, rev. Apr. 2021 ********************************************************/ #include #include #include "xprs.h" #include "xprs_mse_defaulthandler.h" int main(int argc, char **argv) { XPRSprob prob; XPRSmipsolpool msp; XPRSmipsolenum mse; int i, s, nSols, solID, nCols, solStatus, presolveOps, maxSols; double objval, sol; /* Initialize Xpress */ if (XPRSinit(NULL)) { printf("Failed to initialize Xpress.\n"); return -1; } XPRScreateprob(&prob); /* Create a new problem */ XPRSreadprob(prob, "folio10_7.lp", ""); /* Read the problem matrix */ /* Get the number of columns in the problem */ XPRSgetintattrib(prob, XPRS_ORIGINALCOLS, &nCols); /* Create a mip solution pool to store the solutions */ XPRS_msp_create(&msp); /* Create a mip solution enumerator to run the search */ XPRS_mse_create(&mse); /* Disable heuristics to avoid duplicate solutions being found and stored */ XPRSsetintcontrol(prob, XPRS_HEUREMPHASIS, 0); /* Prevent dual reductions from removing dominated solutions. */ XPRSsetintcontrol(prob, XPRS_MIPDUALREDUCTIONS, 0); /* Run the enumeration */ maxSols = 10; XPRS_mse_maxim(mse, prob, msp, XPRS_mse_defaulthandler, NULL, &maxSols); /* Get the number of solutions found */ XPRS_mse_getintattrib(mse, XPRS_MSE_SOLUTIONS, &nSols); /* Print out the solutions found */ for(i=1; i<=nSols; i++) { XPRS_mse_getsollist(mse, XPRS_MSE_METRIC_MIPOBJECT, i, i, &solID, NULL, NULL); XPRS_mse_getsolmetric(mse, solID, &solStatus, XPRS_MSE_METRIC_MIPOBJECT, &objval); printf("--------\nSolution %d: Objective: %g\n", i, objval); for(s=0; s