plasmo-dev / Plasmo.jl

A Platform for Scalable Modeling and Optimization
Other
150 stars 21 forks source link

getValue() doesnt seem to work with VariableRef arguments #45

Closed etatara closed 11 months ago

etatara commented 2 years ago

JuMP.value(node::OptiNode,vref::VariableRef) throws an error:

ERROR: KeyError: key Symbol("##260") not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, MathOptInterface.ModelLike}, key::Symbol)
   @ Base ./dict.jl:482
 [2] value(node::OptiNode, vref::VariableRef)
   @ Plasmo ~/julia-1.6.2/share/julia/packages/Plasmo/s5YhC/src/optinode.jl:48
 [3] top-level scope
   @ REPL[22]:1

This can be replicated in the example optigraph_4_nodes.jl by calling:

JuMP.value(node, node[:x])

In optinode.jl:48, the call to JuMP.backend(node).result_location[node.id] throws the error because the node.id symbol is different from the key in the result_location dict.

etatara commented 2 years ago

It seems like just using JuMP.value(node[:x]) works OK.

jalving commented 2 years ago

Thanks for reporting this. Both versions are supposed to work. I'll push out a fix asap.

jalving commented 11 months ago

This should now be fixed by #93.

Just FYI, fixing this revealed another issue with running optimize! on a node after a graph. It is normally possible to track separate solutions on a node versus the graphs that contain it. Right now, if you optimize a node directly, it will clear all of solutions on each graph. I'll plan to file an issue with a working example.