-
Notifications
You must be signed in to change notification settings - Fork 6
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
How to use NOMAD with a function that depends on both the parameters to be optimized (x) and fixed parameters (p)? #71
Comments
We have a parameter called FIXED_VARIABLES for that. And we have an example for Nomad in batch mode. |
@martinmestre The interface of the NOMAD software in Julia does not include the parameter FIXED_VARIABLES, because it is difficult to test it when combined with linear equality constraints (between others). You need to launch it only on non-fixed variables. However, the following example should do the deal: import NOMAD
function bb1(x, p)
sum1 = sum(cos.(x) .^ 4)
sum2 = sum(x)
sum3 = (1:length(x)) .* x
prod1 = prod(cos.(x) .^ 2)
prod2 = prod(x)
g1 = -prod2 + 0.75
g2 = sum2 - 7.5 * length(x)
f = 10 * g1 + 10 * g2
if (sum3 ≠ 0.0)
f -= abs((sum1 - 2 * prod1) / sqrt(3))
end
# scaling
f *= 10^(-5) + p
c2000 = -f - 2000 + p
return (true, true, [g1; g2; f; c2000])
end
for param in [1.0, 2.0, 2.0, 3.0] #include two times 2.0 for reproducibility
println("parameter = ", param, "\n")
pb = NOMAD.NomadProblem(5, 4, ["PB"; "PB"; "OBJ"; "EB"],
x -> bb1(x, param))
pb.options.max_bb_eval = 1000
result = NOMAD.solve(pb, 7.0 * ones(Float64, 5))
end On my machine, it returns:
Hope it helps ! We will add a remark in the documentation. |
Hi, I would really appreciate an example on this. Thanks.
The text was updated successfully, but these errors were encountered: