NLOPT constraint violation

Hi
I am using NLOP for topology optimization. First I did the deterministic topology optimization with constraint on volume, Now I am adding another constraint. As I checked the values for constraint it seems that the design is violating the second constraint and not trying to satisfy the second constraint. Do you have any comments on this or how can I fix the issue?
Thank you

function gf_p_optimize(p_init;u0, r, β, η, TOL, MAX_ITER, fem_params)
    ##################### Optimize #################
    opt = Opt(:LD_MMA, fem_params.np)
    opt.lower_bounds = 0.001
    opt.upper_bounds = 1
    opt.xtol_rel = TOL
    opt.maxeval = MAX_ITER
    opt.min_objective = (p0, grad) -> gf_p(p0, grad;u0, r, β, η, fem_params)
    inequality_constraint!(opt, (p0, gradc) -> cf_p(p0, gradc; r, β, η, fem_params), 1e-8)
    inequality_constraint!(opt, (p0, gradlsf) -> lsf_pc(p0, gradlsf; r, β, η, fem_params), 1e-8)
    (g_opt, p_opt, ret) = optimize(opt, p_init)
    @show numevals = opt.numevals # the number of function evaluations
    println("got $g_opt after $numevals iterations (returned $ret)")
    return g_opt, p_opt

end; 

Hi @mary, I’ve moved this question to the optimization section.

A few questions to help us understand the issue:

  • How did you check that the constraint was violated? Was it violated by a large value or a small value?
  • Did you check the ret code from the optimizer? Did it claim to find a feasible point or did it encounter an error?

It’s a bit hard to tell only by looking at this function in isolation. Can you provide a reproducible example?