示例#1
0
void SPxSolver::qualBoundViolation(
   Real& maxviol, Real& sumviol) const
{
   maxviol = 0.0;
   sumviol = 0.0;

   DVector solu( nCols() );

   getPrimal( solu );

   for( int col = 0; col < nCols(); ++col )
   {
      assert( lower( col ) <= upper( col ));

      Real viol = 0.0;

      if (solu[col] < lower( col ))
         viol = spxAbs( solu[col] - lower( col ));
      else
         if (solu[col] > upper( col ))
            viol = spxAbs( solu[col] - upper( col ));
         
      if (viol > maxviol)
         maxviol = viol;

      sumviol += viol;
   }
}
示例#2
0
void SPxSolver::qualSlackViolation(Real& maxviol, Real& sumviol) const
{
   maxviol = 0.0;
   sumviol = 0.0;

   DVector solu( nCols() );
   DVector slacks( nRows() );

   getPrimal( solu );
   getSlacks( slacks );

   for( int row = 0; row < nRows(); ++row )
   {
      const SVector& rowvec = rowVector( row );

      Real val = 0.0;         

      for( int col = 0; col < rowvec.size(); ++col )
         val += rowvec.value( col ) * solu[rowvec.index( col )];

      Real viol = spxAbs(val - slacks[row]);

      if (viol > maxviol)
         maxviol = viol;

      sumviol += viol;
   }
}
示例#3
0
void SPxSolver::qualConstraintViolation(Real& maxviol, Real& sumviol) const
{
   maxviol = 0.0;
   sumviol = 0.0;

   DVector solu( nCols() );

   getPrimal( solu );

   for( int row = 0; row < nRows(); ++row )
   {
      const SVector& rowvec = rowVector( row );

      Real val = 0.0;         

      for( int col = 0; col < rowvec.size(); ++col )
         val += rowvec.value( col ) * solu[rowvec.index( col )];

      Real viol = 0.0;

      assert(lhs( row ) <= rhs( row ));

      if (val < lhs( row )) 
         viol = spxAbs(val - lhs( row ));
      else
         if (val > rhs( row ))
            viol = spxAbs(val - rhs( row ));

      if (viol > maxviol)
         maxviol = viol;

      sumviol += viol;
   }
}
示例#4
0
 Residuals(const Problem& problem, const Omega& omega, const Psi& psi)
     : normOfC{problem.c.norm()},
       normOfB{problem.b.norm()},
       AXPlusS{problem.A * omega.x + psi.s},
       ATransposeY{problem.A.transpose() * omega.y},
       cTransposeX{problem.c.transpose() * omega.x},
       bTranspoesY{problem.b.transpose() * omega.y},
       primal{getPrimal(problem, omega, psi)},
       dual{getDual(problem, omega)},
       primalDualGap{getGap(problem, omega)},
       unbounded{cTransposeX < 0 ? AXPlusS.norm() * normOfC / -cTransposeX
                                 : NAN},
       infeasible{bTranspoesY < 0 ? ATransposeY.norm() * normOfB / -bTranspoesY
                                  : NAN} {}