JuMP/CPLEX: retrieve value of array-variables in callback

The Ref has nothing to do with callback_value specifically, but is a trick used together with any broadcasted functions (i.e., with the dot between name and starting parenthesis). Every argument to a broadcasted function need to be a “container” of sorts, if it is a single element, the single element is used for each of the multiple calls, if it has multiple elements, each element is used in a different call (the first element of all vectors with multiple elements is used in the first call, then the second, and so on) and the results are assembled in a collection (often a Vector) and returned (y_val and z_val in your case).

Any other single-element zero-dimensional container works, I use the tuple constructor actually:

y_val = callback_value.((cb_data,), model[:y])
z_val = callback_value.((cb_data,), model[:z])
2 Likes