Skip to content
Snippets Groups Projects
Commit e8dfa1c2 authored by Tom Fischer's avatar Tom Fischer
Browse files

Added parameter for penalty to applyKnownSolution(), some formatting.

parent 78491466
No related branches found
No related tags found
No related merge requests found
...@@ -22,18 +22,18 @@ ...@@ -22,18 +22,18 @@
namespace MathLib namespace MathLib
{ {
void applyKnownSolution(LisMatrix &A, LisVector &b, const std::vector<std::size_t> &_vec_knownX_id, const std::vector<double> &_vec_knownX_x) void applyKnownSolution(LisMatrix &A, LisVector &b, const std::vector<std::size_t> &vec_knownX_id,
const std::vector<double> &vec_knownX_x, double penalty_scaling)
{ {
//Use penalty parameter //Use penalty parameter
const double penalty_scaling = 1e+10; const double max_diag_coeff = A.getMaxDiagCoeff();
const double _max_diag_coeff = A.getMaxDiagCoeff(); const double penalty = max_diag_coeff * penalty_scaling;
const double penalty = _max_diag_coeff * penalty_scaling; INFO("-> max. absolute value of diagonal entries = %e", max_diag_coeff);
INFO("-> max. absolute value of diagonal entries = %e", _max_diag_coeff);
INFO("-> penalty scaling = %e", penalty_scaling); INFO("-> penalty scaling = %e", penalty_scaling);
const std::size_t n_bc = _vec_knownX_id.size(); const std::size_t n_bc = vec_knownX_id.size();
for (std::size_t i_bc=0; i_bc<n_bc; i_bc++) { for (std::size_t i_bc=0; i_bc<n_bc; i_bc++) {
const std::size_t rowId = _vec_knownX_id[i_bc]; const std::size_t rowId = vec_knownX_id[i_bc];
const double x = _vec_knownX_x[i_bc]; const double x = vec_knownX_x[i_bc];
//A(k, k) = penalty //A(k, k) = penalty
A.setValue(rowId, rowId, penalty); A.setValue(rowId, rowId, penalty);
//b(k) = x*penalty //b(k) = x*penalty
......
...@@ -29,10 +29,13 @@ class LisVector; ...@@ -29,10 +29,13 @@ class LisVector;
* *
* @param A Coefficient matrix * @param A Coefficient matrix
* @param b RHS vector * @param b RHS vector
* @param _vec_knownX_id a vector of known solution entry IDs * @param vec_knownX_id a vector of known solution entry IDs
* @param _vec_knownX_x a vector of known solutions * @param vec_knownX_x a vector of known solutions
* @param penalty_scaling value for scaling some matrix and right hand side
* entries to enforce some conditions
*/ */
void applyKnownSolution(LisMatrix &A, LisVector &b, const std::vector<std::size_t> &_vec_knownX_id, const std::vector<double> &_vec_knownX_x); void applyKnownSolution(LisMatrix &A, LisVector &b, const std::vector<std::size_t> &_vec_knownX_id,
const std::vector<double> &_vec_knownX_x, double penalty_scaling = 1e+10);
} // MathLib } // MathLib
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment