Comments (3)
Are you using the low-level interface? You can make a closure. If the function you want to write looks like eval_f(x, data)
then just send x -> eval_f(x, data)
as the function when you call createProblem
. On Julia 0.5 that should be the same performance. On Julia 0.4 it might have a little bit of a performance penalty but for a large problem most of the time should be spent in the Ipopt linear algebra rather than function evaluations.
from ipopt.jl.
Thanks for the reply.
I am using Julia interface (5.0) . As you said I made a closure as follows:
function testfunc(x,data)
function eval_f(x,data)
println(data)
return x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3]
end
return eval_f
end
.
.
.
global data = 10
prob = createProblem(n, x_L, x_U, m, g_L, g_U, 8, 10,
testfunc, eval_g, eval_grad_f, eval_jac_g, eval_h)
.
.
.
data is defined as a global variable. Now I have this error: Could you please tell what is wrong here?
ERROR: LoadError: MethodError: no method matching testFunc(::Array{Float64,1})
Closest candidates are:
testFunc(::Any, !Matched::Any) at /Users/fatimachegini/.julia/v0.5/Ipopt/example/hs071.jl:11
in eval_f_wrapper(::Int32, ::Ptr{Float64}, ::Int32, ::Ptr{Float64}, ::Ptr{Void}) at /Users/fatimachegini/.julia/v0.5/Ipopt/src/Ipopt.jl:89
in solveProblem(::Ipopt.IpoptProblem) at /Users/fatimachegini/.julia/v0.5/Ipopt/src/Ipopt.jl:304
in include_from_node1(::String) at ./loading.jl:426
in include_from_node1(::String) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
in process_options(::Base.JLOptions) at ./client.jl:262
in _start() at ./client.jl:318
in _start() at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
while loading /Users/fatimachegini/.julia/v0.5/Ipopt/example/hs071.jl, in expression starting on line 113
from ipopt.jl.
Hi,
I defined the data as a global variable, now it works.
from ipopt.jl.
Related Issues (20)
- add `MathOptInterface.Name()` attribute HOT 1
- `max_wall_time` is still not working HOT 5
- Allow user to specify the Ipopt binary HOT 2
- copy_to does not copy attributes for variable bound constraints HOT 6
- Only evaluate QP callbacks if needed HOT 1
- Problem with HSL solvers since updating to MacOS 13.0 HOT 3
- double free or corruption (out) error HOT 20
- Linking full hsl library to Ipopt.jl on ubuntu HOT 19
- julia 0.6.0 install Ipopt cannot connect to mumps dependency HOT 2
- Add support for GetIpoptCurrentViolations
- Incorrect number of Hessian structure (nonzero entries) HOT 10
- Does Ipopt.jl support giving hessian matrix in JuMP directly, without using the C_wrapper? HOT 2
- pointer being freed was not allocated HOT 33
- Invalid number in NLP function or derivative detected. HOT 8
- Issue with non-negative variable tolerance. HOT 2
- does not allow Ipopt_jll current version HOT 2
- Add some pre-built "debugging" callbacks HOT 1
- Crash on Windows when optimizing with SPRAL_jll HOT 11
- Using Ipopt in parallel threads HOT 4
- "double free or corruption" when providing duplicate hessian entries via MathOptInterface HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipopt.jl.