The objective is to solve a large system of NL equations. Equations should be obtained via polynomial operations and passed on to JuMP as user-defined function. Below is the minuaturised code for eveluating polynomials’ variables as function’s arguments: using JuMP using Ipopt using MultivariatePolynomials using DynamicPolynomials function f(k_1,c_1) c_1*k_1^2 end @polyvar c_1 k_1 s d=2*k_1^2+c_1-s p5=subs(d,s=>f(k_1,c_1)) function y_2(c,k) p5(c_1=>c,k_1=>k) end y_2(c,k)
The error message is the following when I call for the evaluated function: UndefVarError: c not defined

Please, what is wrong in the code? How differently can I convert MultivariatePolynomials output into user-defined functions usable into JuMP?

When I register y_2(c,k) as a user defined function in the real model, I receive the following error:

`AssertionError: Variable c_1 was not assigned a value`
`Stacktrace:`
`[1]_subsmap(::MultivariatePolynomials.Eval,::Array{DynamicPolynomials.PolyVar{true},1},::Tuple{Pair{DynamicPolynomials.PolyVar{true},Float64},`
`Pair{DynamicPolynomials.PolyVar{true},Float64},Pair{DynamicPolynomials.PolyVar{true},Float64},Pair{DynamicPolynomials.PolyVar{true},Float64},Pair{DynamicPolynomials.PolyVar{true},Float64},.....`

It is difficult to tell you what is the issue without a minimal working example but it could be cause by calling @polyvar twice. Indeed, in DynamicPolynomials, the equality between variables is not based on the name, each variable is different. For instance,

using JuMP
using Ipopt
using MultivariatePolynomials
using DynamicPolynomials
function f(k_1,c_1)
c_1*k_1^2
end
@polyvar c_1 k_1 s
d=2*k_1^2+c_1-s
p5=subs(d,s=>f(k_1,c_1))
@polyvar c_1
function y_3(c,k)
p5(c_1=>c,k_1=>k)
end
m = Model()
@variable m c
@variable m k
y_3(c, k)

throws the error AssertionError: Variable c_1 was not assigned a value because the c_1 using in p5(c_1=>c,k_1=>k) is different than the c_1 used in d=2*k_1^2+c_1-s and p5=subs(d,s=>f(k_1,c_1)).