From bea83227394482bbed681de30f314a05f3605763 Mon Sep 17 00:00:00 2001
From: Mohamed Tarek <mohamed82008@gmail.com>
Date: Sat, 14 May 2022 09:10:51 +0200
Subject: [PATCH] minor changes

---
 Project.toml         | 2 +-
 src/mma_algorithm.jl | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Project.toml b/Project.toml
index b0c8ea1..4edf20e 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "NonconvexMMA"
 uuid = "d3d89cbb-4ecd-4604-818d-8d1ff343e4da"
 authors = ["Mohamed Tarek <mohamed82008@gmail.com> and contributors"]
-version = "0.1.2"
+version = "0.1.3"
 
 [deps]
 ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
diff --git a/src/mma_algorithm.jl b/src/mma_algorithm.jl
index 79da50d..305d112 100755
--- a/src/mma_algorithm.jl
+++ b/src/mma_algorithm.jl
@@ -112,7 +112,7 @@ end
 function MMAWorkspace(
     model::VecModel,
     optimizer::AbstractOptimizer,
-    x0::AbstractVector;
+    x0::AbstractVector{T};
     options = default_options(model, optimizer),
     convcriteria::ConvergenceCriteria = KKTCriteria(),
     plot_trace::Bool = false,
@@ -120,8 +120,7 @@ function MMAWorkspace(
     save_plot = nothing,
     callback::Function = plot_trace ? LazyPlottingCallback(; show_plot = show_plot, save_plot = save_plot) : NoCallback(),
     kwargs...,
-)
-    T = eltype(x0)
+) where {T}
     init!(model)
     dualmodel = MMADualModel(MMAApproxModel(model, x0; kwargs...))
 
@@ -466,8 +465,7 @@ function increaseρ!(
 end
 
 function getoptimobj(obj, minimize = true)
-    optimobj(z) = optimobj(1.0, nothing, z)
-    function optimobj(F, G, z)
+    return (F, G, z) -> begin
         if G !== nothing
             val, grad = value_gradient(obj, z)
             if minimize
@@ -493,5 +491,4 @@ function getoptimobj(obj, minimize = true)
         end
         return nothing
     end
-    return optimobj
 end