# Add an "optimize\_assert\_optimal" functionality in JuMP would be handier?

**URL:** https://discourse.julialang.org/t/add-an-optimize-assert-optimal-functionality-in-jump-would-be-handier/124458
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [January 6, 2025, 2:41am UTC](https://discourse.julialang.org/t/add-an-optimize-assert-optimal-functionality-in-jump-would-be-handier/124458 "2025-01-06T02:41:48Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)
#### Post date: [January 8, 2025, 2:49pm UTC](https://discourse.julialang.org/t/add-an-optimize-assert-optimal-functionality-in-jump-would-be-handier/124458/4 "2025-01-08T14:49:41Z")

</div>

This is an actual experiment I’m doing currently. And JuMP give me Warning message without mentioning the name of the model I’ve established. Therefore I am not able to locate the source of this Warning. @odow

```julia
julia> while true                                                                                                              
           opt_ass_opt(trh, "trh")                                                                                             
           x = jvr6.(trh_x); oLh_check = JuMP.value(oLh); lb = JuMP.objective_bound(trh);                                      
           JuMP.fix.(tr2_x, x) # 🖌️                                                                                            
           proper_Q = get_proper_Q(x) # ✅                                                                                     
           updVec .= false                                                                                                     
           for j in 1:proper_Q[1]                                                                                              
               Y = proper_Q[3][:, :, j]                                                                                        
               JuMP.fix.(tr2_Y, Y) # 🖌️                                                                                        
               opt_ass_opt(tr2, "tr2")                                                                                         
               b2 = jvr6.(tr2_b2); oΛ2_check = JuMP.value(oΛ2) # 🥑✂️                                                          
               set_argZ_objective(x, Y, b2); opt_ass_optortime(argZ, "argZ")                                                   
               Z_new = jvr6.(argZ_Z)                                                                                           
               cn, px, pY, pb = JuMP.value(argZ_cn), jvr6.(argZ_c_x), jvr6.(argZ_c_Y), jvr6.(argZ_c_b2)                        
               if oΛ2_check < cn + ip(px, x) + ip(pY, Y) + ip(pb, b2) - UPDTOL                                                 
                   add_cut_for_oΛ2(cn, px, pY, pb)                                                                             
                   updVec[2] = true                                                                                            
               end                                                                                                             
               recruit(Z_list, Z_new)                                                                                          
               proper_P = get_proper_P(x, Y, Z_list) # ✅                                                                      
               add_cut_for_oLh(x, proper_Q, proper_P, oLh_check) && (updVec[1] = true)                                         
           end                                                                                                                 
           @info "$updVec, lb = $lb"                                                                                           
           all(updVec .== false) && break                                                                                      
       end
[Info: Bool[1, 1], lb = -208.90723332481141
┌ Warning: The addition operator has been used on JuMP expressions a large number of times. This warning is safe to ignore but may indicate that model generation is slower than necessary. For performance reasons, you should not add expressions in a loop. Instead of x += y, use add_to_expression!(x,y) to modify x in place. If y is a single variable, you may also use add_to_expression!(x, coef, y) for x += coef*y.
└ @ JuMP K:\judepot1112\packages\JuMP\i68GU\src\operators.jl:282
[Info: Bool[1, 1], lb = 0.6
[Info: Bool[1, 1], lb = 1.23
[Info: Bool[1, 1], lb = 1.23

```

As you can see (restricted to the code I’ve posted here), there are 3 models `trh`, `tr2` and `argZ`.  
And for some information about this Warning, you can check this post if you have time, thanks.

> [@Inner product grammar is neater than sum(index) in JuMP modeling, But triggers Warning?](https://discourse.julialang.org/t/inner-product-grammar-is-neater-than-sum-index-in-jump-modeling/124528):
>
> Continuing the discussion from [JuMP slow model generation](https://discourse.julialang.org/t/jump-slow-model-generation/1623): I figured out a novel neat way to write a particular kind of constraint, however it trigger warnings like the above post did. Can we somehow improve this? see the following code ############## An motivating example ############## import JuMP I = 4 # change 4 to 20004 to see the Warning M\_vector = [rand(2, 3) for \_ in 1:I]; M\_mean = rand(2, 3); model = JuMP.Model(); # The following line create a probability decision vector JuMP.@variab…

---

_[View the full topic](https://discourse.julialang.org/t/add-an-optimize-assert-optimal-functionality-in-jump-would-be-handier/124458)._
