MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / addRow

Method addRow

src/openms/source/DATASTRUCTURES/LPWrapper.cpp:76–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75
76 Int LPWrapper::addRow(const std::vector<Int>& row_indices, const std::vector<double>& row_values, const String& name) // return index
77 {
78 if (row_indices.size() != row_values.size())
79 {
80 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Indices and values vectors differ in size");
81 }
82#if COINOR_SOLVER == 1
83 model_->addRow((int)row_indices.size(), row_indices.data(), row_values.data(), -COIN_DBL_MAX, COIN_DBL_MAX, name.c_str());
84 return model_->numberRows() - 1;
85#else
86 std::vector<Int> row_indices_ = row_indices;
87 std::vector<double> row_values_ = row_values;
88 const Int index = glp_add_rows(lp_problem_, 1);
89 // glpk accesses arrays beginning at index 1-> we have to insert an empty value at the front
90 row_indices_.insert(row_indices_.begin(), -1);
91 row_values_.insert(row_values_.begin(), -1);
92 for (Int& row_index : row_indices_)
93 {
94 ++row_index;
95 }
96 glp_set_mat_row(lp_problem_, index, (int)row_indices_.size() - 1, row_indices_.data(), row_values_.data());
97 glp_set_row_name(lp_problem_, index, name.c_str());
98 return index - 1;
99#endif
100 }
101
102 Int LPWrapper::addColumn()
103 {

Callers

nothing calls this directly

Calls 4

setRowBoundsMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected