- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10
JSO Compliance : LM #200
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
          
     Merged
      
      
    
  
     Merged
                    JSO Compliance : LM #200
Changes from 8 commits
      Commits
    
    
            Show all changes
          
          
            17 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      58f26a1
              
                start LM update
              
              
                MaxenceGollier 3ffc73b
              
                JSO-compliant LM draft
              
              
                MaxenceGollier 02b6cce
              
                make LMModel type stable
              
              
                MaxenceGollier 458aae8
              
                improve type stability in LM
              
              
                MaxenceGollier 5101a10
              
                add LM doc
              
              
                MaxenceGollier 144f9a4
              
                add LM function signatures
              
              
                MaxenceGollier 576bb88
              
                update tests
              
              
                MaxenceGollier f85deac
              
                solve function signature bugs
              
              
                MaxenceGollier 53c40b8
              
                remove dead code
              
              
                MaxenceGollier 3c8e92e
              
                apply julia formatter
              
              
                MaxenceGollier de6a62b
              
                implicit jacobian update
              
              
                MaxenceGollier 63b9e3a
              
                Merge branch 'JuliaSmoothOptimizers:master' into LM-JSO
              
              
                MaxenceGollier b4cb5b7
              
                remove temporary struct
              
              
                MaxenceGollier 25fc1da
              
                Merge branch 'JuliaSmoothOptimizers:master' into LM-JSO
              
              
                MaxenceGollier 77ddd78
              
                update callback docstring
              
              
                MaxenceGollier 69e8409
              
                Merge branch 'JuliaSmoothOptimizers:master' into LM-JSO
              
              
                MaxenceGollier 7df41cc
              
                fix arrow prints
              
              
                MaxenceGollier File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| export LMModel | ||
|  | ||
| @doc raw""" | ||
| LMModel(j_prod!, jt_prod, F, v, σ, xk) | ||
|  | ||
| Given the unconstrained optimization problem: | ||
| ```math | ||
| \min \tfrac{1}{2} \| F(x) \|^2, | ||
| ``` | ||
| this model represents the smooth LM subproblem: | ||
| ```math | ||
| \min_s \ \tfrac{1}{2} \| F(x) + J(x)s \|^2 + \tfrac{1}{2} σ \|s\|^2 | ||
| ``` | ||
| where `J` is the Jacobian of `F` at `xk`, represented via matrix-free operations. | ||
| `j_prod!(xk, s, out)` computes `J(xk) * s`, and `jt_prod!(xk, r, out)` computes `J(xk)' * r`. | ||
|  | ||
| `σ > 0` is a regularization parameter and `v` is a vector of the same size as `F(xk)` used for intermediary computations. | ||
| """ | ||
| mutable struct LMModel{T <: Real, V <: AbstractVector{T}, J <: Function , Jt <: Function} <: | ||
| AbstractNLPModel{T, V} | ||
| j_prod!::J | ||
| jt_prod!::Jt | ||
| F::V | ||
| v::V | ||
| xk::V | ||
| σ::T | ||
| meta::NLPModelMeta{T, V} | ||
| counters::Counters | ||
| end | ||
|         
                  dpo marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| function LMModel(j_prod!::J, jt_prod!::Jt, F::V, σ::T, xk::V) where {T, V, J, Jt} | ||
| meta = NLPModelMeta( | ||
| length(xk), | ||
| x0 = xk, # Perhaps we should add lvar and uvar as well here. | ||
| ) | ||
| v = similar(F) | ||
| return LMModel(j_prod!, jt_prod!, F, v, xk, σ, meta, Counters()) | ||
| end | ||
|  | ||
| function NLPModels.obj(nlp::LMModel, x::AbstractVector{T}) where{T} | ||
| @lencheck nlp.meta.nvar x | ||
| increment!(nlp, :neval_obj) | ||
| nlp.j_prod!(nlp.xk, x, nlp.v) # v = J(xk)x | ||
| nlp.v .+= nlp.F | ||
| return ( dot(nlp.v, nlp.v) + nlp.σ * dot(x, x) ) / 2 | ||
| end | ||
|  | ||
| function NLPModels.grad!(nlp::LMModel, x::AbstractVector{T}, g::AbstractVector{T}) where{T} | ||
| @lencheck nlp.meta.nvar x | ||
| @lencheck nlp.meta.nvar g | ||
| increment!(nlp, :neval_grad) | ||
| nlp.j_prod!(nlp.xk, x, nlp.v) # v = J(xk)x + F | ||
| nlp.v .+= nlp.F | ||
| nlp.jt_prod!(nlp.xk, nlp.v, g) # g = J^T(xk) v | ||
| @. g += nlp.σ .* x | ||
| return g | ||
| end | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.