Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorials Code return "UndefVarError: ForwardConstraintFunction not defined" #221

Closed
dmayfrank opened this issue Apr 27, 2022 · 2 comments
Closed

Comments

@dmayfrank
Copy link

Hello,
sorry, this is probably a pretty basic question, I'm very new to Julia.

I'm trying to run the tutorial-files but I always get an error when trying to set the sensitivities. For example in line 140 of matrix-inversion-manual.jl (https://github.com/jump-dev/DiffOpt.jl/blob/master/docs/src/examples/matrix-inversion-manual.jl).

The full error message is:
_UndefVarError: ForwardConstraintFunction not defined

Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base ./Base.jl:35
[2] top-level scope
@ In[1]:140
[3] eval
@ ./boot.jl:373 [inlined]
[4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196_

I tried adding these two lines of code which I found in another example, but this also did not help:

import MathOptInterface
const MOI = MathOptInterface

Apart from that I'm also struggling to understand the meaning of the syntax in the code used to set the sensitivities:

# set sentivitity
MOI.set(
    model,
    DiffOpt.ForwardConstraintFunction(),
    cons[1],
    0.0 * index(x[1]) - 1.0,  # to indicate the direction vector to get directional derivatives
)

and in the code used to query the derivatives:

# Query derivative
dx = MOI.get.(
    model,
    DiffOpt.ForwardVariablePrimal(),
    x,
)

Is there some documentation on these functions somewhere?

Thanks a lot for your help!

@matbesancon
Copy link
Collaborator

hi, thanks for reaching out, this is because of a breaking change which happened in recent PRs #210 #214 #216
To have it working, you need to add the master branch of DiffOpt instead of the stable version, we will release a new version soon

See here here to add a package on a given branch

@dmayfrank
Copy link
Author

Thanks for the quick response, it works now!

I will try to understand the exact meaning of the syntax in the code mentioned above tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants