Commit a0e47ef4 authored by Martin Marinov's avatar Martin Marinov

Minor improvements to code whitespace style and clarity. Add some progress ticks.

parent dcc31ac2
This diff is collapsed.
...@@ -35,11 +35,13 @@ ...@@ -35,11 +35,13 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include "GMM_Tools.hh" #include "GMM_Tools.hh"
#define GMM_USES_LAPACK #define GMM_USES_LAPACK
#include <gmm/gmm_lapack_interface.h> #include <gmm/gmm_lapack_interface.h>
#include <queue>
#include <CoMISo/Utils/VSToolsT.hh>
#include <CoMISo/Utils/VSToolsT.hh>
#include <Base/Debug/DebOut.hh>
#include <queue>
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
...@@ -961,19 +963,19 @@ int gauss_seidel_local( MatrixT& _A, VectorT& _x, VectorT& _rhs, std::vector<uns ...@@ -961,19 +963,19 @@ int gauss_seidel_local( MatrixT& _A, VectorT& _x, VectorT& _rhs, std::vector<uns
template<class MatrixT, class VectorT> template<class MatrixT, class VectorT>
double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs ) double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs )
{ {
if ( gmm::mat_ncols( _A ) != _x.size() ) if (gmm::mat_ncols(_A) != _x.size())
std::cerr << "DIM ERROR (residuum_norm): " << gmm::mat_ncols( _A ) << " vs " << _x.size() << std::endl; std::cerr << "DIM ERROR (residuum_norm): " << gmm::mat_ncols(_A) << " vs " << _x.size() << std::endl;
if ( gmm::mat_nrows( _A) !=_rhs.size() ) if (gmm::mat_nrows(_A) != _rhs.size())
std::cerr << "DIM ERROR 2 (residuum_norm): " << gmm::mat_nrows( _A) << " vs " << _rhs.size() << std::endl; std::cerr << "DIM ERROR 2 (residuum_norm): " << gmm::mat_nrows(_A) << " vs " << _rhs.size() << std::endl;
// temp vectors // temp vectors
VectorT Ax( _rhs.size()); VectorT Ax(_rhs.size());
VectorT res( _rhs.size() ); VectorT res(_rhs.size());
gmm::mult( _A,_x, Ax ); gmm::mult(_A, _x, Ax);
gmm::add( Ax, gmm::scaled( _rhs, -1.0 ), res ); gmm::add(Ax, gmm::scaled(_rhs, -1.0), res);
return gmm::vect_norm2( res ); return gmm::vect_norm2(res);
} }
...@@ -983,29 +985,31 @@ double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs ) ...@@ -983,29 +985,31 @@ double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs )
template<class MatrixT, class MatrixT2, class VectorT> template<class MatrixT, class MatrixT2, class VectorT>
void factored_to_quadratic( MatrixT& _F, MatrixT2& _Q, VectorT& _rhs) void factored_to_quadratic( MatrixT& _F, MatrixT2& _Q, VectorT& _rhs)
{ {
DEB_enter_func;
gmm::size_type m = gmm::mat_nrows(_F); gmm::size_type m = gmm::mat_nrows(_F);
gmm::size_type n = gmm::mat_ncols(_F); gmm::size_type n = gmm::mat_ncols(_F);
// resize result matrix and vector // resize result matrix and vector
gmm::resize(_Q, n-1, n-1); gmm::resize(_Q, n - 1, n - 1);
gmm::resize(_rhs, n); gmm::resize(_rhs, n);
// // set up transposed // // set up transposed
// MatrixT Ft(n,m); // MatrixT Ft(n,m);
// gmm::copy(gmm::transposed(_F), Ft); // gmm::copy(gmm::transposed(_F), Ft);
// compute quadratic matrix // compute quadratic matrix
MatrixT Q(n,n); MatrixT Q(n, n);
// gmm::mult(Ft,_F,Q); // gmm::mult(Ft,_F,Q);
gmm::mult(gmm::transposed(_F),_F,Q); gmm::mult(gmm::transposed(_F), _F, Q);
PROGRESS_TICK;
// extract rhs // extract rhs
gmm::copy( gmm::scaled(gmm::mat_const_row( Q, n - 1),-1.0), _rhs); gmm::copy(gmm::scaled(gmm::mat_const_row(Q, n - 1), -1.0), _rhs);
// resize and copy output // resize and copy output
gmm::resize( Q, n-1, n-1); gmm::resize(Q, n - 1, n - 1);
_rhs.resize( n - 1); _rhs.resize(n - 1);
gmm::copy ( Q, _Q); PROGRESS_TICK;
gmm::copy(Q, _Q);
} }
......
...@@ -97,22 +97,22 @@ MISolver::solve( ...@@ -97,22 +97,22 @@ MISolver::solve(
DEB_out(2, "# integer variables: " << _to_round.size() DEB_out(2, "# integer variables: " << _to_round.size()
<< "\n# continuous variables: " << _x.size()-_to_round.size() << "\n") << "\n# continuous variables: " << _x.size()-_to_round.size() << "\n")
// nothing to solve? // nothing to solve?
if( gmm::mat_ncols(_A) == 0 || gmm::mat_nrows(_A) == 0) if( gmm::mat_ncols(_A) == 0 || gmm::mat_nrows(_A) == 0)
return; return;
if( gurobi_rounding_) if( gurobi_rounding_)
solve_gurobi(_A, _x, _rhs, _to_round); solve_gurobi(_A, _x, _rhs, _to_round);
else if( cplex_rounding_) else if( cplex_rounding_)
solve_cplex(_A, _x, _rhs, _to_round); solve_cplex(_A, _x, _rhs, _to_round);
else if( no_rounding_ || _to_round.size() == 0) else if( no_rounding_ || _to_round.size() == 0)
solve_no_rounding( _A, _x, _rhs); solve_no_rounding( _A, _x, _rhs);
else if( direct_rounding_) else if( direct_rounding_)
solve_direct_rounding( _A, _x, _rhs, _to_round); solve_direct_rounding( _A, _x, _rhs, _to_round);
else if( multiple_rounding_) else if( multiple_rounding_)
solve_multiple_rounding( _A, _x, _rhs, _to_round); solve_multiple_rounding( _A, _x, _rhs, _to_round);
else else
solve_iterative( _A, _x, _rhs, _to_round, _fixed_order); solve_iterative( _A, _x, _rhs, _to_round, _fixed_order);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment