Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Oct 6, 2023
1 parent 0fa0060 commit 93b6e56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[extensions]
ManoptJuMPExt = "JuMP"
ManoptJuMPExt = ["JuMP", "Manifolds"]
ManoptLRUCacheExt = "LRUCache"
ManoptLineSearchesExt = "LineSearches"
ManoptManifoldsExt = ["Manifolds"]
Expand Down
10 changes: 6 additions & 4 deletions ext/ManoptJuMPExt.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module ManoptJuMPExt

using Manopt
using LinearAlgebra
using JuMP: JuMP
const MOI = JuMP.MOI
using ManifoldsBase
using ManifoldDiff
using Manifolds

function __init__()
# So that the user can use the convenient `Manopt.Optimizer`
Expand Down Expand Up @@ -43,8 +45,8 @@ using JuMP
"""
mutable struct Optimizer <: MOI.AbstractOptimizer
manifold::Union{Nothing,ManifoldsBase.AbstractManifold}
problem::Union{Nothing,AbstractManoptProblem}
state::Union{Nothing,AbstractManoptSolverState}
problem::Union{Nothing,Manopt.AbstractManoptProblem}
state::Union{Nothing,Manopt.AbstractManoptSolverState}
variable_primal_start::Vector{Union{Nothing,Float64}}
sense::MOI.OptimizationSense
nlp_model::MOI.Nonlinear.Model
Expand Down Expand Up @@ -308,14 +310,14 @@ end

function MOI.get(model::Optimizer, attr::MOI.ObjectiveValue)
MOI.check_result_index_bounds(model, attr)
solution = get_solver_return(model.state)
solution = Manopt.get_solver_return(model.state)
return get_cost(model.problem, solution)
end

function MOI.get(model::Optimizer, attr::MOI.VariablePrimal, vi::MOI.VariableIndex)
MOI.check_result_index_bounds(model, attr)
MOI.throw_if_not_valid(model, vi)
solution = get_solver_return(get_objective(model.problem), model.state)
solution = Manopt.get_solver_return(get_objective(model.problem), model.state)
return solution[vi.value]
end

Expand Down

0 comments on commit 93b6e56

Please sign in to comment.