void dy_setfinalstatus (void) /* This code is common to all three start routines (coldstart, warmstart, hotstart). It scans the newly calculated basic variables and assigns them their final status. In the process, it calculates the number of infeasible variables, and the total infeasibility. Parameters: none Returns: undefined */ { int aindx, xkndx ; double xk,lbk,ubk ; # ifdef DYLP_PARANOIA const char *rtnnme = "dy_setfinalstatus" ; # endif # ifndef DYLP_NDEBUG if (dy_opts->print.crash >= 2) dyio_outfmt(dy_logchn,dy_gtxecho,"\n\testablishing final status ...") ; # endif dy_lp->infeas = 0.0 ; dy_lp->infeascnt = 0 ; /* Step through the constraints, and have a look at the basic variable in each position. The paranoid check will complain if the basis is corrupt, but since nothing can go wrong if we're not paranoid, it just complains and moves to the next entry. */ for (aindx = 1 ; aindx <= dy_sys->concnt ; aindx++) { xkndx = dy_basis[aindx] ; xk = dy_xbasic[aindx] ; lbk = dy_sys->vlb[xkndx] ; ubk = dy_sys->vub[xkndx] ; # ifdef DYLP_PARANOIA if (xkndx <= 0 || xkndx > dy_sys->varcnt) { errmsg(303,rtnnme,dy_sys->nme,aindx,1,xkndx,dy_sys->varcnt) ; continue ; } # endif switch (dy_status[xkndx]) { case vstatB: { if (atbnd(xk,lbk)) { dy_status[xkndx] = vstatBLB ; } else if (belowbnd(xk,lbk)) { dy_lp->infeascnt++ ; dy_lp->infeas += lbk-xk ; dy_status[xkndx] = vstatBLLB ; } else if (atbnd(xk,ubk)) { dy_status[xkndx] = vstatBUB ; } else if (abovebnd(xk,ubk)) { dy_lp->infeascnt++ ; dy_lp->infeas += xk-ubk ; dy_status[xkndx] = vstatBUUB ; } break ; } case vstatBFX: { if (!atbnd(xk,lbk)) { if (belowbnd(xk,lbk)) { dy_lp->infeascnt++ ; dy_lp->infeas += lbk-xk ; dy_status[xkndx] = vstatBLLB ; } else { dy_lp->infeascnt++ ; dy_lp->infeas += xk-ubk ; dy_status[xkndx] = vstatBUUB ; } } break ; } } # ifndef DYLP_NDEBUG if (dy_opts->print.crash >= 4) { dyio_outfmt(dy_logchn,dy_gtxecho,"\n\t %s (%d) %s", consys_nme(dy_sys,'v',xkndx,FALSE,NULL),xkndx, dy_prtvstat(dy_status[xkndx])) ; if (lbk > -dy_tols->inf) dyio_outfmt(dy_logchn,dy_gtxecho,", lb = %g",lbk) ; dyio_outfmt(dy_logchn,dy_gtxecho,", val = %g",xk) ; if (ubk < dy_tols->inf) dyio_outfmt(dy_logchn,dy_gtxecho,", ub = %g",ubk) ; if (flgon(dy_status[xkndx],vstatBLLB|vstatBUUB)) { dyio_outfmt(dy_logchn,dy_gtxecho,", infeasibility = ") ; if (flgon(dy_status[xkndx],vstatBLLB)) dyio_outfmt(dy_logchn,dy_gtxecho,"%g",lbk-xk) ; else dyio_outfmt(dy_logchn,dy_gtxecho,"%g",xk-ubk) ; } dyio_outchr(dy_logchn,dy_gtxecho,'.') ; } # endif } setcleanzero(dy_lp->infeas,dy_tols->zero) ; return ; }
void dy_logStatus (lpprob_struct *orig_lp, flags **p_logstat) /* This routine returns the status of the primal logical variables, in row order for the original system. The routine reports out the full set of dylp status codes. It's actually a fair bit of work to get the status right for inactive constraints. Because we're reporting the full set of dylp status codes, and the client might be calling in a situation where the outcome was infeasible or unbounded, we need to calculate the value and assign the appropriate status code. Parameters: orig_lp: the original lp problem p_logstat: (i) vector to hold the status of the primal logical variables; if NULL, a vector of appropriate size will be allocated (o) status of the primal logical variables, in the original system frame of reference Returns: undefined */ { int i,m,i_orig,m_orig ; flags stati ; double rhsi,rhslowi,lhsi,xi,lbi,ubi ; consys_struct *orig_sys ; flags *logstat ; double *x ; char *rtnnme = "dy_logStatus" ; # ifndef DYLP_NDEBUG int v,n_orig ; # endif # ifdef DYLP_PARANOIA if (dy_std_paranoia(orig_lp,rtnnme) == FALSE) { return ; } if (p_logstat == NULL) { errmsg(2,rtnnme,"logstat") ; return ; } # endif orig_sys = orig_lp->consys ; m_orig = orig_sys->concnt ; m = dy_sys->concnt ; /* If we're not playing with a full deck, we'll need the values of the architecturals to determine the appropriate status for the logical. */ x = NULL ; if (m < m_orig) { dy_colPrimals(orig_lp,&x) ; } /* Do we need a vector? */ if (*p_logstat != NULL) { logstat = *p_logstat ; memset(logstat,0,(m_orig+1)*sizeof(flags)) ; } else { logstat = (flags *) CALLOC((m_orig+1),sizeof(flags)) ; } /* Walk the rows of the original system. For active constraints, copy the status of the logical from dy_status. For inactive constraints, we need to actually calculate the value of the logical and assign the appropriate status. This is more work than you'd think, because we need to determine the appropriate bounds for the logical based on the constraint type, and we need to allow for the possibility that the problem was infeasible or unbounded and the logical is not within bounds. We also need to allow for the possibility that dylp deactivated a tight constraint with y<i> = 0. The convention for logicals in the original system is that all have a coefficient of 1.0. Thus we have bounds of (0,infty) for a slack (contypLE), (0,0) for an artificial (contypEQ), (-infty,0) for a surplus (contypGE), and (0,rhs-rhslow) for a bounded slack (contypRNG). */ for (i_orig = 1 ; i_orig <= m_orig ; i_orig++) { if (ACTIVE_CON(i_orig)) { i = dy_origcons[i_orig] ; stati = dy_status[i] ; } else { lhsi = consys_dotrow(orig_sys,i_orig,x) ; rhsi = orig_sys->rhs[i_orig] ; xi = rhsi-lhsi ; setcleanzero(xi,dy_tols->zero) ; lbi = -dy_tols->inf ; ubi = dy_tols->inf ; switch (orig_sys->ctyp[i_orig]) { case contypLE: { lbi = 0.0 ; break ; } case contypEQ: { lbi = 0.0 ; ubi = 0.0 ; break ; } case contypGE: { ubi = 0.0 ; break ; } case contypRNG: { rhslowi = orig_sys->rhslow[i_orig] ; lbi = 0 ; ubi = rhsi-rhslowi ; break ; } case contypNB: { continue ; } default: { errmsg(1,rtnnme,__LINE__) ; break ; } } if (belowbnd(xi,lbi)) { stati = vstatBLLB ; } else if (atbnd(xi,lbi)) { stati = vstatBLB ; } else if (atbnd(xi,ubi)) { stati = vstatBUB ; } else if (abovebnd(xi,ubi)) { stati = vstatBUUB ; } else { stati = vstatB ; } } logstat[i_orig] = stati ; } if (x != NULL) FREE(x) ; # ifndef DYLP_NDEBUG if (dy_opts->print.soln >= 3) { dyio_outfmt(dy_logchn,dy_gtxecho,"\n\trowstat =") ; n_orig = orig_sys->varcnt ; v = 0 ; for (i_orig = 1 ; i_orig <= m_orig ; i_orig++) { if ((++v)%3 == 0) { v = 0 ; dyio_outfmt(dy_logchn,dy_gtxecho,"\n\t ") ; } dyio_outfmt(dy_logchn,dy_gtxecho," (%s %d %s)", consys_nme(orig_sys,'v',i_orig+n_orig,FALSE,NULL),i_orig, dy_prtvstat(logstat[i_orig])) ; } } # endif /* That's it. Return the vector. */ *p_logstat = logstat ; return ; }