Commit 4171cfa3 authored by David Bommes's avatar David Bommes

fixed bug in constraint conversion for empty constraint vector

parent ededd54a
Pipeline #16509 failed with stages
in 4 minutes and 6 seconds
......@@ -238,7 +238,8 @@ public:
int solve_experimental(NProblemInterface* _problem, std::vector<NConstraintInterface*>& _constraints, std::vector<LinearConstraint>& _linear_constraints)
{
DEB_time_func_def;
DEB_enter_func;
// DEB_time_func_def;
converged_ = false;
DEB_line_if(!silent_,2, "*** optimize via AugmentedLagrangianMethod with " << _problem->n_unknowns() << " unknowns and " << _constraints.size() << " constraints");
......
......@@ -70,11 +70,11 @@ public:
// }
template <class SMatrixT, class VectorT>
static void nsolver_to_eigen( std::vector<LinearConstraint>& _constraints, SMatrixT& _A, VectorT& _b)
static void nsolver_to_eigen( std::vector<LinearConstraint>& _constraints, SMatrixT& _A, VectorT& _b, int _n_variables = 0)
{
if(_constraints.empty())
{
_A.resize(0,0);
_A.resize(0,_n_variables);
_b.resize(0);
return;
}
......
......@@ -1145,7 +1145,9 @@ public:
// It is also required that the constraints are linearly independent
int solve_projected_normal_equation( NProblemInterface* _problem, const SMatrixD& _A, const VectorD& _b )
{
DEB_time_func_def;
// DEB_time_func_def;
DEB_enter_func;
converged_ = false;
// number of unknowns
......@@ -1396,7 +1398,7 @@ public:
// convert constraints
SMatrixD A;
VectorD b;
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b);
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b, _problem->n_unknowns());
return solve(_problem, A, b);
}
......@@ -1406,7 +1408,7 @@ public:
// convert constraints
SMatrixD A;
VectorD b;
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b);
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b, _problem->n_unknowns());
return solve_experimental(_problem, A, b);
}
......@@ -1416,7 +1418,7 @@ public:
// convert constraints
SMatrixD A;
VectorD b;
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b);
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b, _problem->n_unknowns());
return solve_reduced_system(_problem, A, b);
}
......@@ -1426,7 +1428,7 @@ public:
// convert constraints
SMatrixD A;
VectorD b;
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b);
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b, _problem->n_unknowns());
return solve_reduced_system_EigenCG(_problem, A, b);
}
......@@ -1436,7 +1438,7 @@ public:
// convert constraints
SMatrixD A;
VectorD b;
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b);
LinearConstraintConverter::nsolver_to_eigen(_constraints, A, b, _problem->n_unknowns());
return solve_projected_normal_equation(_problem, A, b);
}
......
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