Commit abc65889 authored by Henrik Zimmer's avatar Henrik Zimmer
Browse files

* Namespace change ACG -> COMISO

* Stability update: upon eliminating very small entries e.g. 1e-16 are set to zero, to avoid unnecessary fill-in of almost zero elements


git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@31 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 409f6e83
......@@ -111,7 +111,7 @@ int main(void)
gmm::row_matrix< gmm::wsvector< double > > Ccpy( C );
// create a constrained solver
ACG::ConstrainedSolver cs;
COMISO::ConstrainedSolver cs;
// vector of indices to round (this is the mixed-integer part)
std::vector< int > ids_to_round;
// lets say we want to round the third variable
......@@ -172,7 +172,7 @@ int main(void)
std::cout << "---------- ---------- 3.4) solve the system using the mixed-integer solver..." << std::endl;
// create solver
ACG::MISolver miso;
COMISO::MISolver miso;
// miso solve
miso.solve( BtBCSC, x, rhs, ids_to_round);
std::cout << " solution vector x is\n" << x << std::endl << std::endl;
......
......@@ -137,7 +137,7 @@ int main(void)
gmm::col_matrix< gmm::wsvector< double > > Acpy( A );
// create a constrained solver
ACG::ConstrainedSolver cs;
COMISO::ConstrainedSolver cs;
// vector of indices to round (this is the mixed-integer part)
std::vector< int > ids_to_round;
// lets say we want to round the third variable
......@@ -174,7 +174,7 @@ int main(void)
std::cout << "---------- ---------- 4.3) solve the system using the mixed-integer solver..." << std::endl;
// create solver
ACG::MISolver miso;
COMISO::MISolver miso;
// miso solve
miso.solve( Acsc, x, b, ids_to_round);
std::cout << " solution vector x is\n" << x << std::endl << std::endl;
......
......@@ -83,7 +83,7 @@ int main(void)
std::cout << "---------- 2) The original solution to this system is..." << std::endl;
ACG::ConstrainedSolver cs;
COMISO::ConstrainedSolver cs;
// void solve( RMatrixT& _constraints, RMatrixT& _B, VectorT& _x, VectorIT& _idx_to_round, double _reg_factor = 0.0, bool _show_miso_settings = true, bool _show_timings = true );
//_show_miso_settings requires a QT context and hence must be false in this example
cs.solve( constraints, B, x, ids_to_round, 0.0, false, true);
......
......@@ -86,7 +86,7 @@ int main(void)
std::cout << "---------- 2) The original solution to this system is..." << std::endl;
ACG::ConstrainedSolver cs;
COMISO::ConstrainedSolver cs;
//void solve( RMatrixT& _constraints, CMatrixT& _A, VectorT& _x, VectorT& _rhs, VectorIT& _idx_to_round, double _reg_factor = 0.0, bool _show_miso_settings = true, bool _show_timings = true );
//_show_miso_settings requires a QT context and hence must be false in this example
cs.solve( constraints, A, x, b, ids_to_round, 0.0, false, true);
......
......@@ -106,7 +106,7 @@ int main(void)
// make conditions independent
std::vector< int > idx_to_round, c_elim(gmm::mat_nrows(C));
ACG::ConstrainedSolver cs;
COMISO::ConstrainedSolver cs;
cs.make_constraints_independent( C, idx_to_round, c_elim);
//std::cerr << "C indep " << C << std::endl;
//c_elim[0]=1;
......@@ -178,7 +178,7 @@ int main(void)
// test quadratic elimination
//std::cerr << " A " << A << std::endl;
ACG::StopWatch sw;
COMISO::StopWatch sw;
sw.start();
gmm::eliminate_constraints(C, A, x, rhs, idx_to_round, c_elim, new_idx);
......@@ -197,9 +197,9 @@ int main(void)
//std::cerr << " C " << C << std::endl;
gmm::row_matrix< gmm::wsvector<double> > Brow(gmm::mat_nrows(B), gmm::mat_ncols(B));
gmm::copy(B,Brow);
ACG::StopWatch sw1;
ACG::StopWatch sw2;
ACG::StopWatch sw3;
COMISO::StopWatch sw1;
COMISO::StopWatch sw2;
COMISO::StopWatch sw3;
double time1=0.0, time2=0.0, time3=0.0;
gmm::col_matrix< gmm::wsvector<double > > Btt;
sw.start();
......
......@@ -39,7 +39,7 @@
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== IMPLEMENTATION ==========================================================
......@@ -129,7 +129,7 @@ slotCancelButton()
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#endif
......@@ -30,8 +30,8 @@
//=============================================================================
#ifndef ACG_MISOLVERDIALOG_HH
#define ACG_MISOLVERDIALOG_HH
#ifndef COMISO_MISOLVERDIALOG_HH
#define COMISO_MISOLVERDIALOG_HH
//== INCLUDES =================================================================
......@@ -50,14 +50,14 @@
//== NAMESPACES ===============================================================
namespace ACG
namespace COMISO
{
//== CLASS DEFINITION =========================================================
/** \class MISolverDialog MISolverDialog.hh <ACG/.../MISolverDialog.hh>
/** \class MISolverDialog MISolverDialog.hh <COMISO/.../MISolverDialog.hh>
Brief Description.
......@@ -101,9 +101,9 @@ private:
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#endif // ACG_MISOLVERDIALOG_HH defined
#endif // COMISO_MISOLVERDIALOG_HH defined
//=============================================================================
#endif
......@@ -29,7 +29,7 @@
#include "CholmodSolver.hh"
namespace ACG {
namespace COMISO {
CholmodSolver::CholmodSolver()
{
......
......@@ -29,8 +29,8 @@
//
//=============================================================================
#ifndef ACG_CHOLMOD_SOLVER_HH
#define ACG_CHOLMOD_SOLVER_HH
#ifndef COMISO_CHOLMOD_SOLVER_HH
#define COMISO_CHOLMOD_SOLVER_HH
//== INCLUDES =================================================================
......@@ -48,7 +48,7 @@ typedef struct cholmod_factor_struct cholmod_factor;
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== CLASS DEFINITION =========================================================
class COMISODLLEXPORT CholmodSolver
......@@ -96,12 +96,12 @@ private:
};
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(ACG_CHOLMOD_SOLVER_TEMPLATES_C)
#define ACG_CHOLMOD_SOLVER_TEMPLATES
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_CHOLMOD_SOLVER_TEMPLATES_C)
#define COMISO_CHOLMOD_SOLVER_TEMPLATES
#include "CholmodSolverT.cc"
#endif
//=============================================================================
#endif // ACG_CHOLMOD_SOLVER_HH defined
#endif // COMISO_CHOLMOD_SOLVER_HH defined
//=============================================================================
......@@ -24,12 +24,12 @@
#define ACG_CHOLMOD_SOLVER_TEMPLATES_C
#define COMISO_CHOLMOD_SOLVER_TEMPLATES_C
#include "CholmodSolver.hh"
namespace ACG {
namespace COMISO {
template< class GMM_MatrixT>
......
......@@ -27,7 +27,7 @@
#include <gmm/gmm.h>
namespace ACG {
namespace COMISO {
//-----------------------------------------------------------------------------
......
......@@ -30,8 +30,8 @@
//=============================================================================
#ifndef ACG_CONSTRAINEDSOLVER_HH
#define ACG_CONSTRAINEDSOLVER_HH
#ifndef COMISO_CONSTRAINEDSOLVER_HH
#define COMISO_CONSTRAINEDSOLVER_HH
//== INCLUDES =================================================================
......@@ -47,7 +47,7 @@
#define ROUND(x) ((x)<0?int((x)-0.5):int((x)+0.5))
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== CLASS DEFINITION =========================================================
/** \class ConstrainedSolver ConstrainedSolver.hh <ACG/.../ConstrainedSolver.hh>
......@@ -62,7 +62,7 @@ public:
/// default Constructor
ConstrainedSolver() { epsilon_ = 1e-6; noisy_ = 1; }
ConstrainedSolver() { epsilon_ = 1e-8; epsilon_squared_ = 1e-16; noisy_ = 1; }
/// Destructor
~ConstrainedSolver() { }
......@@ -204,7 +204,7 @@ public:
/*@}*/
/// Set numerical epsilon for valid constraint coefficient
void set_epsilon( double _epsilon) { epsilon_ = _epsilon;}
void set_epsilon( double _epsilon) { epsilon_ = _epsilon; epsilon_squared_ = epsilon_*epsilon_;}
/// Set noise-level (how much std output is given) 0 basically none, 1 important stuff (warning/timing, is default), 2+ not so important
void set_noisy( int _noisy) { noisy_ = _noisy;}
......@@ -275,18 +275,19 @@ private:
ConstrainedSolver& operator=(const ConstrainedSolver& _rhs);
double epsilon_;
double epsilon_squared_;
int noisy_;
};
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(ACG_CONSTRAINEDSOLVER_C)
#define ACG_CONSTRAINEDSOLVER_TEMPLATES
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_CONSTRAINEDSOLVER_C)
#define COMISO_CONSTRAINEDSOLVER_TEMPLATES
#include "ConstrainedSolverT.cc"
#endif
//=============================================================================
#endif // ACG_CONSTRAINEDSOLVER_HH defined
#endif // COMISO_CONSTRAINEDSOLVER_HH defined
//=============================================================================
......@@ -29,7 +29,7 @@
//
//=============================================================================
#define ACG_CONSTRAINEDSOLVER_C
#define COMISO_CONSTRAINEDSOLVER_C
//== INCLUDES =================================================================
#include "ConstrainedSolver.hh"
......@@ -39,7 +39,7 @@
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== IMPLEMENTATION ==========================================================
......@@ -66,7 +66,7 @@ solve(
if( _show_timings) std::cerr << __FUNCTION__ << "\n Initial dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
// StopWatch for Timings
ACG::StopWatch sw, sw2; sw.start(); sw2.start();
COMISO::StopWatch sw, sw2; sw.start(); sw2.start();
// c_elim[i] = index of variable which is eliminated in condition i
// or -1 if condition is invalid
......@@ -132,7 +132,7 @@ solve(
if( _show_timings) std::cerr << __FUNCTION__ << "\n Initital dimension: " << nrows << " x " << ncols << ", number of constraints: " << ncons << std::endl;
// StopWatch for Timings
ACG::StopWatch sw, sw2; sw.start(); sw2.start();
COMISO::StopWatch sw, sw2; sw.start(); sw2.start();
// c_elim[i] = index of variable which is eliminated in condition i
// or -1 if condition is invalid
......@@ -152,7 +152,7 @@ solve(
if( _show_timings) std::cerr << "Eliminated dimension: " << Acsc.nr << " x " << Acsc.nc << std::endl;
// create MISO solver
ACG::MISolver miso;
COMISO::MISolver miso;
// show options dialog
if( _show_miso_settings)
miso.show_options_dialog();
......@@ -186,7 +186,7 @@ make_constraints_independent(
VectorIT& _idx_to_round,
std::vector<int>& _c_elim)
{
ACG::StopWatch sw;
COMISO::StopWatch sw;
// number of variables
int n_vars = gmm::mat_ncols(_constraints);
......@@ -416,7 +416,7 @@ eliminate_constraints(
std::vector<int>& _new_idx,
CSCMatrixT& _Acsc)
{
ACG::StopWatch sw;
COMISO::StopWatch sw;
sw.start();
// define iterator on matrix A and on constraints C
typedef typename gmm::linalg_traits<SVector2T>::const_iterator AIter;
......@@ -575,6 +575,11 @@ add_row_simultaneously( int _row_i,
{
_rmat(_row_i, r_it.index()) += _coeff*(*r_it);
_cmat(_row_i, r_it.index()) += _coeff*(*r_it);
if( _rmat(_row_i, r_it.index())*_rmat(_row_i, r_it.index()) < epsilon_squared_ )
{
_rmat(_row_i, r_it.index()) = 0.0;
_cmat(_row_i, r_it.index()) = 0.0;
}
}
}
......@@ -591,8 +596,8 @@ setup_and_solve_system( CMatrixT& _B,
double _reg_factor,
bool _show_miso_settings)
{
ACG::StopWatch s1;
ACG::StopWatch sw; sw.start();
COMISO::StopWatch s1;
COMISO::StopWatch sw; sw.start();
unsigned int m = gmm::mat_nrows(_B);
unsigned int n = gmm::mat_ncols(_B);
......@@ -646,12 +651,12 @@ setup_and_solve_system( CMatrixT& _B,
double setup_time = sw.stop()/1000.0;
// create solver
ACG::MISolver miso;
COMISO::MISolver miso;
// show options dialog
if( _show_miso_settings)
miso.show_options_dialog();
ACG::StopWatch misw;
COMISO::StopWatch misw;
misw.start();
// miso solve
miso.solve( BtBCSC, _x, rhs, _idx_to_round);
......@@ -899,5 +904,5 @@ ConstrainedSolver::eliminate_columns( CMatrixT& _M,
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
......@@ -211,7 +211,7 @@ void inspect_matrix( const MatrixT& _A);
//=============================================================================
} // namespace ACG
} // namespace gmm
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(GMM_GMM_TOOLS_C)
#define GMM_GMM_TOOLS_TEMPLATES
......
......@@ -35,7 +35,7 @@
#define ROUND(x) ((x)<0?int((x)-0.5):int((x)+0.5))
namespace ACG {
namespace COMISO {
......@@ -92,7 +92,7 @@ MISolver::solve(
old_idx[i] = i;
// Setup Cholmod solver used for full solution
ACG::CholmodSolver chol;
COMISO::CholmodSolver chol;
if( initial_full_solution_ || direct_rounding_)
{
......@@ -298,6 +298,5 @@ show_options_dialog()
}
// end namespace ACG
// end namespace COMISO
}// ----------------------
// end namespace ACG
......@@ -30,8 +30,8 @@
//=============================================================================
#ifndef ACG_MISOLVER_HH
#define ACG_MISOLVER_HH
#ifndef COMISO_MISOLVER_HH
#define COMISO_MISOLVER_HH
//== INCLUDES =================================================================
......@@ -48,13 +48,13 @@
//== FORWARDDECLARATIONS ======================================================
namespace ACG {
namespace COMISO {
class MISolverDialog;
}
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== CLASS DEFINITION =========================================================
......@@ -209,18 +209,18 @@ private:
unsigned int noisy_;
bool stats_;
friend class ACG::MISolverDialog;
friend class COMISO::MISolverDialog;
};
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(ACG_MISOLVER_C)
#define ACG_MISOLVER_TEMPLATES
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_MISOLVER_C)
#define COMISO_MISOLVER_TEMPLATES
#include "MISolverT.cc"
#endif
//=============================================================================
#endif // ACG_MISOLVER_HH defined
#endif // COMISO_MISOLVER_HH defined
//=============================================================================
......@@ -30,14 +30,14 @@
//
//=============================================================================
#define ACG_MISOLVER_C
#define COMISO_MISOLVER_C
//== INCLUDES =================================================================
#include "MISolver.hh"
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== IMPLEMENTATION ==========================================================
......@@ -46,5 +46,5 @@ namespace ACG {
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
......@@ -39,8 +39,8 @@
//=============================================================================
#ifndef ACG_STOPWATCH_HH
#define ACG_STOPWATCH_HH
#ifndef COMISO_STOPWATCH_HH
#define COMISO_STOPWATCH_HH
//== INCLUDES =================================================================
......@@ -62,18 +62,18 @@
//== NAMESPACES ===============================================================
namespace ACG {
namespace COMISO {
//== CLASS DEFINITION =========================================================
/** \class StopWatch StopWatch.hh <ACG/Utils/StopWatch.hh>
/** \class StopWatch StopWatch.hh <COMISO/Utils/StopWatch.hh>
This class can be used for measuring time, providing milli-second
precision by using the gettimeofday() funtion. It is e.g. used in
the class ACG::TimedTracing.
the class COMISO::TimedTracing.
**/
class COMISODLLEXPORT StopWatch
......@@ -154,8 +154,8 @@ private:
//=============================================================================
} // namespace ACG
} // namespace COMISO
//=============================================================================
#endif // ACG_STOPWATCH_HH defined
#endif // COMISO_STOPWATCH_HH defined
//=============================================================================
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