@@ -166,13 +166,12 @@ function set_jump_bounds!(model, sys, pmap)
166166end 
167167
168168function  add_jump_cost_function! (model:: InfiniteModel , sys, tspan, pmap; is_free_t =  false )
169-     jcosts =  MTK. get_costs (sys)
170-     consolidate =  MTK. get_consolidate (sys)
171-     if  isnothing (jcosts) ||  isempty (jcosts)
169+     jcosts =  cost (sys)
170+     if  Symbolics. _iszero (jcosts)
172171        @objective (model, Min, 0 )
173172        return 
174173    end 
175-     jcosts =  substitute_jump_vars (model, sys, pmap, jcosts; is_free_t)
174+     jcosts =  substitute_jump_vars (model, sys, pmap, [ jcosts] ; is_free_t)[ 1 ] 
176175    tₛ =  is_free_t ?  model[:tf ] :  1 
177176
178177    #  Substitute integral
@@ -187,13 +186,12 @@ function add_jump_cost_function!(model::InfiniteModel, sys, tspan, pmap; is_free
187186        hi =  haskey (pmap, hi) ?  1  :  MTK. value (hi)
188187        intmap[int] =  tₛ *  InfiniteOpt.∫ (arg, model[:t ], lo, hi)
189188    end 
190-     jcosts =  map (c  ->   Symbolics. substitute (c , intmap), jcosts )
191-     @objective (model, Min, consolidate (jcosts))
189+     jcosts =  Symbolics. substitute (jcosts , intmap)
190+     @objective (model, Min, MTK . value (jcosts))
192191end 
193192
194193function  add_user_constraints! (model:: InfiniteModel , sys, pmap; is_free_t =  false )
195-     conssys =  MTK. get_constraintsystem (sys)
196-     jconstraints =  isnothing (conssys) ?  nothing  :  MTK. get_constraints (conssys)
194+     jconstraints =  MTK. get_constraints (sys)
197195    (isnothing (jconstraints) ||  isempty (jconstraints)) &&  return  nothing 
198196
199197    if  is_free_t
@@ -206,7 +204,10 @@ function add_user_constraints!(model::InfiniteModel, sys, pmap; is_free_t = fals
206204        end 
207205    end 
208206
209-     auxmap =  Dict ([u =>  MTK. default_toterm (MTK. value (u)) for  u in  unknowns (conssys)])
207+     cons_dvs, cons_ps =  MTK. process_constraint_system (
208+         jconstraints, Set (unknowns (sys)), parameters (sys), MTK. get_iv (sys))
209+ 
210+     auxmap =  Dict ([u =>  MTK. default_toterm (MTK. value (u)) for  u in  cons_dvs])
210211    jconstraints =  substitute_jump_vars (model, sys, pmap, jconstraints; auxmap, is_free_t)
211212
212213    #  Substitute to-term'd variables
0 commit comments