access to coefficients-variables pairs in linear_solver

This commit is contained in:
Laurent Perron
2018-08-01 10:17:08 -07:00
parent cb7aeacfbb
commit 3e013bb5be

View File

@@ -696,6 +696,12 @@ class MPObjective {
// is 0 if the variable does not appear in the objective).
double GetCoefficient(const MPVariable* const var) const;
// Returns a map from variables to their coefficients in the objective. If a
// variable is not present in the map, then its coefficient is zero.
const std::unordered_map<const MPVariable*, double>& terms() const {
return coefficients_;
}
// Sets the constant term in the objective.
void SetOffset(double value);
// Gets the constant term in the objective.
@@ -878,6 +884,12 @@ class MPConstraint {
// is 0 if the variable does not appear in the constraint).
double GetCoefficient(const MPVariable* const var) const;
// Returns a map from variables to their coefficients in the constraint. If a
// variable is not present in the map, then its coefficient is zero.
const std::unordered_map<const MPVariable*, double>& terms() const {
return coefficients_;
}
// Returns the lower bound.
double lb() const { return lb_; }
// Returns the upper bound.