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

Problem with sparse matrix when using CustomGradFunction #152

Closed
bdas123 opened this issue Jul 25, 2022 · 2 comments
Closed

Problem with sparse matrix when using CustomGradFunction #152

bdas123 opened this issue Jul 25, 2022 · 2 comments

Comments

@bdas123
Copy link

bdas123 commented Jul 25, 2022

I get the following error

no method matching sparse(::Float64)

when I use the following code

jacobian = CustomGradFunction(calc_sse, calc_der)
model = Model(jacobian)
addvar!(model, zeros(540), zeros(540).+500, init = x0)
alg = NLoptAlg(:LD_MMA)
options = NLoptOptions(ftol_rel = 1e-6)
@time result = optimize(model, alg, x0, options = options)

The functions calc_sse and calc_der work fine as is.

@mohamed82008
Copy link
Member

Make sure calc_der returns a vector. If there is only 1 variable, it should be a vector of length 1.

@mohamed82008
Copy link
Member

It should be a vector of length 540 in this case it seems.

@bdas123 bdas123 closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants