Commit 44291afc authored by Martin Marinov's avatar Martin Marinov
Browse files

Merged changes from the research branch with fixes in QGP sanitization and...

Merged changes from the research branch with fixes in QGP sanitization and motorcycle graph crash detection. See https://jira.autodesk.com/browse/REFORM-122 for more details.

[git-p4: depot-paths = "//ReForm/ReForm/main/CoMISo/": change = 13557]
parent 3b07dfa7
......@@ -150,12 +150,6 @@ private:
//=============================================================================
#endif // COMISO_CPLEX_AVAILABLE
//=============================================================================
//#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_CPLEXSOLVER_C)
//#define COMISO_CPLEXSOLVER_TEMPLATES
//#include "CPLEXSolverT.cc"
//#endif
//=============================================================================
#endif // ACG_CPLEXSOLVER_HH defined
//=============================================================================
......@@ -10,8 +10,8 @@
#if (COMISO_GUROBI_AVAILABLE && COMISO_BOOST_AVAILABLE)
#if (COMISO_QT_AVAILABLE)
#include <QTemporaryFile>
#include <QFileInfo>
#include <QTemporaryFile>
#include <QFileInfo>
#endif
#include <boost/filesystem.hpp>
......
......@@ -35,7 +35,7 @@ namespace COMISO {
class COMISODLLEXPORT LeastSquaresProblem : public NProblemInterface
{
public:
// Eigen Triplet for Hessian Accumulation
typedef Eigen::Triplet<double> Triplet;
......
......@@ -12,7 +12,7 @@
#include "LinearConstraintHandlerElimination.hh"
#include "LinearConstraintHandlerPenalty.hh"
//#include "LinearConstraintHandlerLagrange.hh"
#include "Base/Debug/DebOut.hh"
#include <Base/Debug/DebOut.hh>
DEB_module("COMISO");
......
......@@ -202,32 +202,32 @@ public:
int ec = sparse_hess( tape_,
this->n_unknowns(),
sparsity_pattern_available,
_x,
&sparse_nz_,
&sparse_r_ind_p_,
&sparse_c_ind_p_,
&sparse_val_p_,
opt);
this->n_unknowns(),
sparsity_pattern_available,
_x,
&sparse_nz_,
&sparse_r_ind_p_,
&sparse_c_ind_p_,
&sparse_val_p_,
opt);
if(ec < 0)
{
#ifdef ADOLC_RET_CODES
std::cout << __FUNCTION__ << " invokes retaping of function due to discontinuity! Return code: " << ec << std::endl;
std::cout << __FUNCTION__ << " invokes retaping of function due to discontinuity! Return code: " << ec << std::endl;
#endif
// Retape function if return code indicates discontinuity
tape_available_ = false;
eval_f(_x);
ec = sparse_hess( tape_,
this->n_unknowns(),
sparsity_pattern_available,
_x,
&sparse_nz_,
&sparse_r_ind_p_,
&sparse_c_ind_p_,
&sparse_val_p_,
opt);
// Retape function if return code indicates discontinuity
tape_available_ = false;
eval_f(_x);
ec = sparse_hess( tape_,
this->n_unknowns(),
sparsity_pattern_available,
_x,
&sparse_nz_,
&sparse_r_ind_p_,
&sparse_c_ind_p_,
&sparse_val_p_,
opt);
}
// data should be available now
......
......@@ -40,7 +40,7 @@
#include <CoMISo/Config/CoMISoDefines.hh>
#include <CoMISo/Utils/StopWatch.hh>
#include <Base/Utils/StopWatch.hh>
#include <iostream>
#include <vector>
......@@ -107,7 +107,7 @@ private:
std::vector<int> rowind_;
bool show_timings_;
StopWatch sw_;
Base::StopWatch sw_;
};
//=============================================================================
......
......@@ -224,7 +224,7 @@ solve(
int ncons = gmm::mat_nrows(_constraints);
DEB_out_if( _show_timings, 1, "Initital dimension: " << nrows << " x " << ncols
<< ", number of constraints: " << ncons
<< ", number of constraints: " << ncons
<< " use reordering: " << use_constraint_reordering() << "\n")
// StopWatch for Timings
......@@ -393,8 +393,8 @@ void
ConstrainedSolver::
make_constraints_independent(
RMatrixT& _constraints,
VectorIT& _idx_to_round,
std::vector<int>& _c_elim)
VectorIT& _idx_to_round,
std::vector<int>& _c_elim)
{
DEB_enter_func;
// setup linear transformation for rhs, start with identity
......@@ -530,10 +530,10 @@ make_constraints_independent(
}
else
{
DEB_warning_if( ( noisy_ > 0) && !do_gcd_, 1,
DEB_warning_if( ( noisy_ > 0) && !do_gcd_, 1,
"NO +-1 coefficient found, integer rounding cannot be guaranteed. Try using the GCD option! "
<< DEB_os_str( gmm::mat_const_row(_constraints, i)) )
DEB_warning_if( ( noisy_ > 0) && do_gcd_, 1,
DEB_warning_if( ( noisy_ > 0) && do_gcd_, 1,
"GCD of non-integer cannot be computed! "
<< DEB_os_str( gmm::mat_const_row(_constraints, i)) )
}
......@@ -582,8 +582,8 @@ void
ConstrainedSolver::
make_constraints_independent_reordering(
RMatrixT& _constraints,
VectorIT& _idx_to_round,
std::vector<int>& _c_elim)
VectorIT& _idx_to_round,
std::vector<int>& _c_elim)
{
DEB_enter_func;
// setup linear transformation for rhs, start with identity
......@@ -742,15 +742,15 @@ make_constraints_independent_reordering(
else
{
if( noisy_ > 0)
{
if( !do_gcd_)
DEB_warning(1, "NO +-1 coefficient found, integer rounding cannot be guaranteed. Try using the GCD option! "
{
if( !do_gcd_)
DEB_warning(1, "NO +-1 coefficient found, integer rounding cannot be guaranteed. Try using the GCD option! "
<< DEB_os_str(gmm::mat_const_row(_constraints, i)) )
else
DEB_warning(1, "GCD of non-integer cannot be computed! "
else
DEB_warning(1, "GCD of non-integer cannot be computed! "
<< DEB_os_str(gmm::mat_const_row(_constraints, i)) )
}
}
}
}
......@@ -1162,8 +1162,8 @@ ConstrainedSolver::
setup_and_solve_system( CMatrixT& _B,
VectorT& _x,
VectorIT& _idx_to_round,
double _reg_factor,
bool _show_miso_settings)
double _reg_factor,
bool _show_miso_settings)
{
DEB_enter_func;
// show options dialog
......@@ -1239,8 +1239,8 @@ void
ConstrainedSolver::
restore_eliminated_vars( RMatrixT& _constraints,
VectorT& _x,
std::vector<int>& _c_elim,
std::vector<int>& _new_idx)
std::vector<int>& _c_elim,
std::vector<int>& _new_idx)
{
DEB_enter_func;
// restore original ordering of _x
......@@ -1290,8 +1290,8 @@ void
ConstrainedSolver::
verify_mi_factored( const RMatrixT& _conditions,
const RMatrixT& _B,
const VectorT& _x,
const VectorIT& _idx_to_round )
const VectorT& _x,
const VectorIT& _idx_to_round )
{
DEB_enter_func;
DEB_out(2, "######### Verify Constrained Solver Result ############\n");
......@@ -1406,7 +1406,7 @@ verify_constrained_system_round(
const VectorT& _x,
const VectorT& _rhs,
const VectorIT& _idx_to_round,
double _eps)
double _eps)
{
DEB_enter_func;
// test integer roundings
......
......@@ -642,7 +642,7 @@ void eigen_to_cholmod_dense( const MatrixT& _A, cholmod_dense* &_AC, cholmod_com
}*/
/*
/*
// convert a gmm col-sparse matrix into an eigen sparse matrix
template<class GMM_MatrixT, class EIGEN_MatrixT>
void gmm_to_eigen( const GMM_MatrixT& _G, EIGEN_MatrixT& _E)
......
......@@ -235,7 +235,7 @@ double residuum_norm( MatrixT& _A, VectorT& _x, VectorT& _rhs );
* @param _rhs right hand side (output) */
template<class MatrixT, class MatrixT2, class VectorT>
void factored_to_quadratic( MatrixT& _F, MatrixT2& _Q, VectorT& _rhs);
template<class MatrixT, class VectorT>
void factored_to_quadratic_rhs_only( MatrixT& _F, VectorT& _rhs);
......
......@@ -99,22 +99,22 @@ MISolver::solve(
DEB_out(2, "# integer variables: " << _to_round.size()
<< "\n# continuous variables: " << _x.size()-_to_round.size() << "\n")
// nothing to solve?
if( gmm::mat_ncols(_A) == 0 || gmm::mat_nrows(_A) == 0)
return;
if( gurobi_rounding_)
solve_gurobi(_A, _x, _rhs, _to_round);
else if( cplex_rounding_)
solve_cplex(_A, _x, _rhs, _to_round);
else if( no_rounding_ || _to_round.size() == 0)
solve_no_rounding( _A, _x, _rhs);
else if( direct_rounding_)
solve_direct_rounding( _A, _x, _rhs, _to_round);
else if( multiple_rounding_)
solve_multiple_rounding( _A, _x, _rhs, _to_round);
else
solve_iterative( _A, _x, _rhs, _to_round, _fixed_order);
// nothing to solve?
if( gmm::mat_ncols(_A) == 0 || gmm::mat_nrows(_A) == 0)
return;
if( gurobi_rounding_)
solve_gurobi(_A, _x, _rhs, _to_round);
else if( cplex_rounding_)
solve_cplex(_A, _x, _rhs, _to_round);
else if( no_rounding_ || _to_round.size() == 0)
solve_no_rounding( _A, _x, _rhs);
else if( direct_rounding_)
solve_direct_rounding( _A, _x, _rhs, _to_round);
else if( multiple_rounding_)
solve_multiple_rounding( _A, _x, _rhs, _to_round);
else
solve_iterative( _A, _x, _rhs, _to_round, _fixed_order);
}
......@@ -129,7 +129,7 @@ MISolver::solve_cplex(
Veci& _to_round)
{
DEB_enter_func;
DEB_out(2, "gurobi_max_time_: " << gurobi_max_time_ << "\n")
DEB_out(2, "gurobi_max_time_: " << gurobi_max_time_ << "\n")
#if COMISO_CPLEX_AVAILABLE
......@@ -580,8 +580,8 @@ MISolver::update_solution(
converged = siter_.conjugate_gradient(_A, _x,_rhs, max_cg_iters, tolerance);
DEB_out_if( noisy_ > 3, 3, "( converged " << converged << " "
<< " iters " << max_cg_iters << " "
<< " res_norm " << tolerance << "\n")
<< " iters " << max_cg_iters << " "
<< " res_norm " << tolerance << "\n")
++n_cg_;
}
......@@ -611,18 +611,18 @@ MISolver::update_solution(
void MISolver::solve_multiple_rounding(
CSCMatrix& _A,
Vecd& _x,
Vecd& _rhs,
Veci& _to_round
)
CSCMatrix& _A,
Vecd& _x,
Vecd& _rhs,
Veci& _to_round
)
{
DEB_enter_func
// StopWatch
Base::StopWatch sw;
double time_search_next_integer = 0;
// StopWatch
Base::StopWatch sw;
double time_search_next_integer = 0;
// some statistics
// some statistics
n_local_ = 0;
n_cg_ = 0;
n_full_ = 0;
......@@ -635,24 +635,24 @@ void MISolver::solve_multiple_rounding(
std::sort(to_round.begin(), to_round.end());
Veci::iterator last_unique;
last_unique = std::unique(to_round.begin(), to_round.end());
int r = last_unique - to_round.begin();
to_round.resize( r);
int r = last_unique - to_round.begin();
to_round.resize( r);
// initialize old indices
Veci old_idx(_rhs.size());
for(unsigned int i=0; i<old_idx.size(); ++i)
old_idx[i] = i;
// initialize old indices
Veci old_idx(_rhs.size());
for(unsigned int i=0; i<old_idx.size(); ++i)
old_idx[i] = i;
if(initial_full_solution_)
{
DEB_out_if( noisy_ > 2, 2, "initial full solution\n")
if(initial_full_solution_)
{
DEB_out_if( noisy_ > 2, 2, "initial full solution\n")
// TODO: we can throw more specific outcomes in the body of the fucntions below
COMISO_THROW_if(!direct_solver_.calc_system_gmm(_A),
UNSPECIFIED_EIGEN_FAILURE);
COMISO_THROW_if(!direct_solver_.solve(_x, _rhs),
UNSPECIFIED_EIGEN_FAILURE);
cholmod_step_done_ = true;
cholmod_step_done_ = true;
++n_full_;
}
......@@ -663,14 +663,14 @@ void MISolver::solve_multiple_rounding(
// Vector for reduced solution
Vecd xr(_x);
// loop until solution computed
for(unsigned int i=0; i<to_round.size(); ++i)
{
// loop until solution computed
for(unsigned int i=0; i<to_round.size(); ++i)
{
DEB_out_if(noisy_ > 0, 1, "Integer DOF's left: " << to_round.size()-(i+1) << " ")
DEB_out_if(noisy_ > 1, 1, "residuum_norm: " << COMISO_GMM::residuum_norm( _A, xr, _rhs) << "\n")
DEB_out_if(noisy_ > 1, 1, "residuum_norm: " << COMISO_GMM::residuum_norm( _A, xr, _rhs) << "\n")
// position in round vector
std::vector<int> tr_best;
// position in round vector
std::vector<int> tr_best;
sw.start();
......@@ -694,14 +694,14 @@ void MISolver::solve_multiple_rounding(
time_search_next_integer += sw.stop();
// nothing more to do?
if( tr_best.empty() )
break;
if( tr_best.empty() )
break;
DEB_out_if( noisy_ > 5, 5,
DEB_out_if( noisy_ > 5, 5,
"round " << tr_best.size() << " variables simultaneously\n")
// clear neigh for local update
neigh_i.clear();
// clear neigh for local update
neigh_i.clear();
for(unsigned int j = 0; j<tr_best.size(); ++j)
{
......@@ -729,13 +729,13 @@ void MISolver::solve_multiple_rounding(
update_solution( _A, xr, _rhs, neigh_i);
}
// final full solution?
if( final_full_solution_)
{
DEB_out_if( noisy_ > 2, 2, "final full solution\n")
// final full solution?
if( final_full_solution_)
{
DEB_out_if( noisy_ > 2, 2, "final full solution\n")
if( gmm::mat_ncols( _A) > 0)
{
if( gmm::mat_ncols( _A) > 0)
{
if(cholmod_step_done_)
direct_solver_.update_system_gmm(_A);
else
......@@ -750,15 +750,15 @@ void MISolver::solve_multiple_rounding(
for(unsigned int i=0; i<old_idx.size(); ++i)
{
_x[ old_idx[i] ] = xr[i];
}
}
// output statistics
DEB_out_if( stats_, 2, " *** Statistics of MiSo Solver ***"
<< "\n Number of CG iterations = " << n_cg_
// output statistics
DEB_out_if( stats_, 2, " *** Statistics of MiSo Solver ***"
<< "\n Number of CG iterations = " << n_cg_
<< "\n Number of LOCAL iterations = " << n_local_
<< "\n Number of FULL iterations = " << n_full_
<< "\n Number of ROUNDING = " << _to_round.size()
<< "\n time searching next integer = "
<< "\n Number of FULL iterations = " << n_full_
<< "\n Number of ROUNDING = " << _to_round.size()
<< "\n time searching next integer = "
<< time_search_next_integer / 1000.0 <<"s\n\n")
}
......
......@@ -107,7 +107,7 @@ public:
* @param _to_round vector with variable indices to round to integers
* @param _fixed_order specifies if _to_round indices shall be rounded in the
* given order (\b true) or be greedily selected (\b false)
* */
* */
void solve(
CSCMatrix& _A,
Vecd& _x,
......@@ -126,7 +126,7 @@ public:
* @param _to_round vector with variable indices to round to integers
* @param _fixed_order specifies if _to_round indices shall be rounded in the
* given order (\b true) or be greedily selected (\b false)
* */
* */
//template<class CMatrixT>
//void solve(
// CMatrixT& _B,
......
......@@ -67,7 +67,7 @@ class COMISODLLEXPORT SparseQRSolver
{
public:
typedef UF_long Int;
typedef SuiteSparse_long Int;
SparseQRSolver();
......
......@@ -43,7 +43,7 @@
#include <CoMISo/Config/CoMISoDefines.hh>
#include "GMM_Tools.hh"
#include <CoMISo/Utils/StopWatch.hh>
#include <Base/Utils/StopWatch.hh>
#include <iostream>
#include <vector>
......@@ -122,7 +122,7 @@ public:
std::vector<int> rowind_;
bool show_timings_;
StopWatch sw_;
Base::StopWatch sw_;
};
//=============================================================================
......
......@@ -3,6 +3,7 @@ set(my_headers
${CMAKE_CURRENT_SOURCE_DIR}/CoMISoErrorInc.hh
${CMAKE_CURRENT_SOURCE_DIR}/MutablePriorityQueueT.hh
${CMAKE_CURRENT_SOURCE_DIR}/SmartPointer.hh
${CMAKE_CURRENT_SOURCE_DIR}/Tools.hh
${CMAKE_CURRENT_SOURCE_DIR}/VSToolsT.hh
PARENT_SCOPE
)
......
/*===========================================================================*\
* *
* CoMISo *
* Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen *
* www.rwth-graphics.de *
* *
*---------------------------------------------------------------------------*
* This file is part of CoMISo. *
* *
* CoMISo is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* CoMISo is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with CoMISo. If not, see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
#ifndef TOOLS_HH
#define TOOLS_HH
#include <math.h>
#include <float.h>
inline int int_round(const double _x)
{
return int(_x >= 0.0 ? _x + 0.5 : _x - 0.5);
}
inline bool same(const double _x, const double _y, const double _tol)
{
return fabs(_x - _y) < _tol;
}
template <typename T> inline T sqr(const T& _a) { return _a * _a; }
//=============================================================================
#endif // TOOLS_HH defined
//=============================================================================
......@@ -22,8 +22,8 @@
* *
\*===========================================================================*/
#ifndef COMISO_VSTOOLS_HH
#define COMISO_VSTOOLS_HH
#ifndef VSTOOLS_HH
#define VSTOOLS_HH
#include <math.h>
#include <float.h>
......@@ -60,18 +60,7 @@ inline int isfinite(double x)
#endif
inline int int_round(const double _x)
{
return int(_x >= 0.0 ? _x + 0.5 : _x - 0.5);
}
inline bool same(const double _x, const double _y, const double _tol)
{
return fabs(_x - _y) < _tol;
}
template <typename T> inline T sqr(const T& _a) { return _a * _a; }
//=============================================================================
#endif // COMISO_VSTOOLS_HH defined
#endif // VSTOOLS_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