When using the z3 optimizing solver, the bounds of models are required especially the constraints are complex. I can find the function upper and lower in the Z3 python api but not be available for the Java api. Could you take some examples showing how to get the model bounds in the Z3 java api?
You should use the Handle
object to access the bounds. The relevant functions are here:
https://github.com/Z3Prover/z3/blob/master/src/api/java/Optimize.java#L92-L103
Z3 comes with a java optimize example which does access the Handle
inside the optimize class. See:
https://github.com/Z3Prover/z3/blob/master/examples/java/JavaExample.java#L2216-L2237
Simply follow that example and further call getLower
and getUpper
, something like:
Optimize.Handle mx = opt.MkMaximize(xExp);
mx.getLower()
mx.getUpper()
Note that min/max values in optimization is not always reliable, nor they mean anything larger than min and smaller than max will be satisfy your constraints. They are merely what the solver kept track of as it was constraining the variable, and might not be what you have in mind. It's best to show what you tried, and what you got when asking stack-overflow questions.