Esempio n. 1
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;
   }
}
Esempio n. 2
0
vector<Scaffold> ScaffoldExtractor::Extract(const DataStore &store, const BranchAndBound &solver)
{
	vector<Scaffold> ans;
	int m = solver.GetSlackCount();
	vector< vector<int> > components;
	vector<bool> slacks(m, true);
	for (int i = 0; i < m; i++)
		if (solver.GetDistanceSlack(i) >= ExtendedFixedMIQPSolver::DesiredDistanceSlackMax || solver.GetOrderSlack(i) >= ExtendedFixedMIQPSolver::DesiredOrderSlackMax)
			slacks[i] = false;
	DPGraph graph(store, solver.T, slacks);
	graph.FindConnectedComponents(components);
	for (int i = 0; i < (int)components.size(); i++)
	{
		int size = components[i].size();
		Scaffold scaffold;
		for (int j = 0; j < size; j++)
			scaffold.AddContig(components[i][j], solver.T[components[i][j]], solver.X[components[i][j]], store[components[i][j]].Sequence.Nucleotides.length());
		scaffold.Sort();
		ans.push_back(scaffold);
	}
	return ans;
}