Created
March 2, 2019 22:08
-
-
Save rschwarz/551c10e7ee19249b326d44d69721562f to your computer and use it in GitHub Desktop.
C wrapper for SCIPexprCreate without variadic arguments of mixed type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "scip/scip.h" | |
/* | |
* To create nonlinear constraints in SCIP, one creates an expression tree whose | |
* nodes are of type SCIP_EXPR*. To create these nodes, there is a variadic | |
* function, SCIPexprCreate: | |
* | |
* SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM* blkmem, SCIP_EXPR** expr, | |
* SCIP_EXPROP op, ...); | |
* | |
* Julia's ccall facility only supports functions with variadic arguments of the | |
* same type, but we sometimes need to call this with mixed types. | |
* | |
* So, we build thin wrappers for different cases, mostly avoiding variadic | |
* arguments, at least with mixed types. | |
*/ | |
SCIP_RETCODE SCIPjlExprCreateVARIDX( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, int varpos) | |
{ | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, varpos) ); | |
return SCIP_OKAY; | |
} | |
SCIP_RETCODE SCIPjlExprCreateCONST( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, SCIP_Real value) | |
{ | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, value) ); | |
return SCIP_OKAY; | |
} | |
SCIP_RETCODE SCIPjlExprCreateREALPOWER( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, SCIP_EXPR* base, SCIP_Real exponent) | |
{ | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, base, exponent) ); | |
return SCIP_OKAY; | |
} | |
SCIP_RETCODE SCIPjlExprCreateUnary( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, SCIP_EXPR* child) | |
{ | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, child) ); | |
return SCIP_OKAY; | |
} | |
SCIP_RETCODE SCIPjlExprCreateBinary( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, SCIP_EXPR* left, SCIP_EXPR* right) | |
{ | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, left, right) ); | |
return SCIP_OKAY; | |
} | |
SCIP_RETCODE SCIPjlExprCreateNAry( | |
BMS_BLKMEM* blkmem, SCIP_EXPR** expr, SCIP_EXPROP op, int nchildren, ...) | |
{ | |
// can't forward variadic arguments, | |
// see http://c-faq.com/varargs/handoff.html ??? | |
SCIP_CALL( SCIPexprCreate(blkmem, expr, op, nchildren, ...) ); | |
return SCIP_OKAY; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment