This function constructs a conditional expression node of type "when",
representing GAMS-style conditional terms using the $ operator,
if ... else ... statements in Julia/JuMP, if ... in ... in Python/Pyomo,
etc.
Arguments
- condition
The condition to check, must be an AST node.
- then
The expression to evaluate if the condition is true (usually the left-hand side).
- otherwise
Optional expression to evaluate if the condition is false. This part is not available in GAMS
$statements, but is useful for other languages.- ...
Additional fields stored on the node (passed to
new_ast()).
Examples
ast_when(
condition = ast_symbol("i_active(i)"),
then = ast_variable("x", c("i"))
)
#> <AST when>
#> condition:
#> <AST symbol> i_active(i)
#> then :
#> <AST variable> x
#> dims: [i]
#> otherwise :
#> NULL
