From a42c3656efa793810f40f75f6253faddd2af9571 Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Thu, 24 Aug 2023 12:39:36 +1000 Subject: [PATCH] Fix ComputeValue(PLConstraint) #200 --- include/mp/flat/constr_eval.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mp/flat/constr_eval.h b/include/mp/flat/constr_eval.h index cf8639e02..30bcb5d3c 100644 --- a/include/mp/flat/constr_eval.h +++ b/include/mp/flat/constr_eval.h @@ -327,12 +327,12 @@ double ComputeValue(const PLConstraint& con, const VarVec& x) { return plp.y_.back() + plp.PostSlope()*(x0 - plp.x_.back()); int i0=0; - for ( ; x0 > plp.x_[i0]; ++i0); + for ( ; x0 > plp.x_[i0]; ++i0) ; return plp.x_[i0]==x0 ? plp.y_[i0] - : plp.y_[i0] - + (plp.y_[i0+1]-plp.y_[i0]) - * (x0-plp.x_[i0]) / (plp.x_[i0+1]-plp.x_[i0]); + : (plp.y_[i0-1] + + (plp.y_[i0]-plp.y_[i0-1]) + * (x0-plp.x_[i0-1]) / (plp.x_[i0]-plp.x_[i0-1])); } /// Should be here,