diff --git a/src/glpapi06.c b/src/glpapi06.c index 4a5267c..f23fb25 100644 --- a/src/glpapi06.c +++ b/src/glpapi06.c @@ -245,7 +245,10 @@ static int solve_lp(glp_prob *P, const glp_smcp *parm) if (ret != 0) goto done; } if (parm->meth == GLP_PRIMAL) - ret = spx_primal(P, parm); + { ret = spx_primal(P, parm); + if (ret == -1 && P->valid) + ret = spx_dual(P, parm); + } else if (parm->meth == GLP_DUALP) { ret = spx_dual(P, parm); if (ret == GLP_EFAIL && P->valid) diff --git a/src/simplex/spxprim.c b/src/simplex/spxprim.c index 3f09b6c..ad29b4f 100644 --- a/src/simplex/spxprim.c +++ b/src/simplex/spxprim.c @@ -1040,6 +1040,12 @@ loop: /* main loop starts here */ xprintf("Perturbation removed at iteration %d\n", csa->it_cnt); #endif + if (check_feas(csa, 2, tol_bnd, tol_bnd1)) + { if (msg_lev >= GLP_MSG_ALL) + xprintf("Switching to dual\n"); + ret = -1; + goto fini; + } } #endif if (csa->beta_st != 1)