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

Add maximize #118

Open
tmigot opened this issue Jul 25, 2023 · 4 comments
Open

Add maximize #118

tmigot opened this issue Jul 25, 2023 · 4 comments
Labels
enhancement New feature or request user-facing Related to user interface and experience

Comments

@tmigot
Copy link
Member

tmigot commented Jul 25, 2023

No description provided.

@tmigot tmigot added enhancement New feature or request good first issue Good for newcomers labels Jul 25, 2023
@Jay-sanjay
Copy link

@tmigot Hello sir , can someone tell me where do I need to add the maximize.

@tmigot
Copy link
Member Author

tmigot commented Oct 1, 2023

The idea was to add a maximize similar to the minimize function. The main difference is when instantiating the NLPModel you would have to make sure that the attribute meta.minimize is set to false.

@Jay-sanjay
Copy link

@tmigot sir when I search for minimize, I am getting several hits .
Do I need to add the maximize function only here

function minimize(
nlp::AbstractNLPModel;
verbose = 1,
highest_derivative_available::Integer = 2,
kwargs...,
)
select = select_optimizers(nlp, verbose, highest_derivative_available)
(verbose 1) && println("Solve using $(first(select).name):")
solver = first(select)
return minimize(Val(Symbol(solver.name)), nlp; verbose = verbose, kwargs...)
end
function minimize(
nlp::AbstractNLSModel;
verbose = 1,
highest_derivative_available::Integer = 2,
kwargs...,
)
select = select_optimizers(nlp, verbose, highest_derivative_available)
nls_select = select[select.specialized_nls, :]
solver = if !isempty(nls_select)
first(nls_select)
else
first(select)
end
(verbose 1) && println("Solve using $(solver.name):")
return minimize(Val(Symbol(solver.name)), nlp; verbose = verbose, kwargs...)
end
function minimize(solver_name::String, nlp; kwargs...)
solver = optimizers[optimizers.name .== solver_name, :]
if isempty(solver)
@warn "$(solver_name) does not exist."
return GenericExecutionStats(nlp)
end
return minimize(Val(Symbol(solver_name)), nlp; kwargs...)
end
function throw_error_solve(solver::Symbol)
solver_pkg = optimizers[optimizers.name .== string(solver), :name_pkg]
if isempty(solver_pkg)
str = "$solver does not exist."
else
solver_pkg = replace(solver_pkg[1], ".jl" => "")
str = "$solver solver package needs to be loaded, please run `using $(solver_pkg)`."
end
return throw(ArgumentError(str))
end
function minimize(::Val{solver_name}, nlp; kwargs...) where {solver_name}
solver = optimizers[optimizers.name .== string(solver_name), :]
if !is_available(solver_name)
throw_error_solve(solver_name)
end
return eval(solver.solve_function[1])(nlp; kwargs...)
end
function is_available(solver::Symbol)
solver_isa = optimizers[optimizers.name .== string(solver), :is_available]
if solver_isa == []
return false
end
return solver_isa[1]
end

or any where else also

@abelsiqueira
Copy link
Member

Hi @Jay-sanjay, it is best to leave this one for a while.

@tmigot tmigot removed the good first issue Good for newcomers label Oct 23, 2023
@abelsiqueira abelsiqueira added the user-facing Related to user interface and experience label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request user-facing Related to user interface and experience
Projects
None yet
Development

No branches or pull requests

3 participants