Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v9-minor'
Browse files Browse the repository at this point in the history
  • Loading branch information
scip-ci committed Apr 19, 2024
2 parents cb731c7 + 71c9801 commit 146af55
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Interface changes

### New API functions

- New function SCIPgetExprActivityNonlinear() to get activity of nonlinear constraint.

### Command line interface

### Interfaces to external software
Expand Down
26 changes: 26 additions & 0 deletions src/scip/cons_nonlinear.c
Original file line number Diff line number Diff line change
Expand Up @@ -13777,6 +13777,32 @@ SCIP_RETCODE SCIPaddExprNonlinear(
return SCIP_OKAY;
}

/** computes value of constraint expression in a given solution
*
* Stores value of constraint expression in sol in activity.
* In case of a domain error (function cannot be evaluated in sol), activity is set to SCIP_INVALID.
*/
SCIP_RETCODE SCIPgetExprActivityNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_SOL* sol, /**< solution */
SCIP_Real* activity /**< buffer to store computed activity */
)
{
SCIP_CONSDATA* consdata;

assert(cons != NULL);
assert(activity != NULL);

consdata = SCIPconsGetData(cons);
assert(consdata != NULL);

SCIP_CALL( SCIPevalExpr(scip, consdata->expr, sol, 0L) );
*activity = SCIPexprGetEvalValue(consdata->expr);

return SCIP_OKAY;
}

/** gets absolute violation of nonlinear constraint
*
* This function evaluates the constraints in the given solution.
Expand Down
13 changes: 13 additions & 0 deletions src/scip/cons_nonlinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,19 @@ SCIP_RETCODE SCIPregisterExprUsageNonlinear(
SCIP_Bool useactivityforsepaabove /**< whether activity of expr will be used by overestimation */
);

/** computes value of constraint expression in a given solution
*
* Stores value of constraint expression in sol in activity.
* In case of a domain error (function cannot be evaluated in sol), activity is set to SCIP_INVALID.
*/
SCIP_EXPORT
SCIP_RETCODE SCIPgetExprActivityNonlinear(
SCIP* scip, /**< SCIP data structure */
SCIP_CONS* cons, /**< constraint */
SCIP_SOL* sol, /**< solution */
SCIP_Real* activity /**< buffer to store computed activity */
);

/** computes absolute violation for auxvar relation in an expression w.r.t. original variables
*
* Assume the expression is f(x), where x are original (i.e., not auxiliary) variables.
Expand Down

0 comments on commit 146af55

Please sign in to comment.