Ryan
Ryan

Reputation: 19

MethodError: no method matching parseNLExpr_runtime

I have an error for the following code in Julia for solving NLP problem.

using JuMP
using Ipopt
using DataFrames,ConditionalJuMP
m = Model(solver=IpoptSolver())

#importing data 

 xi=[-1.016713795   0.804447648 0.932137661 1.064136698  -0.963217531
     -1.048396778   1.076371484 1.099027177 1.061556926  -0.95185481
     -0.980261302   0.271253807 0.184946729 1.062838197  -0.958794505
     -0.980703191   0.278820569 0.231132677 1.062967459  -0.959302488
     -0.953074503   -0.00768112 0.128808175 1.067743779  -0.978524489
     -1.014866259   0.815325963 1.065956208 1.067059122  -0.974682291
     -0.995088119   0.550359991 0.845087207 1.066556784 -0.973154887]
 xj=xi
 pii=[-300
     -259.6530828
     -284.3708955
     -291.3387625
     -342.4479859
     -356.5031603
     -351.0154738]

 sample_size=7
 bus_num=5
 tempsum=0
 #define variables
 @variable(m,aij[1:2*bus_num,1:2*bus_num]) # define  matrix by 
                                             2bus_num*2bus_num

 for n=1:sample_size
    for i=1:bus_num
       for j=1:bus_num
        tempsum=(aij[i,j]*xi[n,i]*xj[n,j]-pii[n,2])^2+tempsum
       end
    end
 end

 #define constraints
 @constraint(m, [i=1:2*bus_num,j=2*bus_num],aij[i,j]==aij[j,i])
 @constraint(m, [i=1:2*bus_num,j=2*bus_num],aij[i,j]*aij[i,j]<=aij   
 [i,i]*aij[j,j])
 @constraint(m, [i=1:2*bus_num,j=2*bus_num],aij[i,i]*aij[j,j]<=0.25*
 (aij[i,i]+aij[j,j])*(aij[i,i]+aij[j,j]))

 #define NLP objective function

 @NLobjective(m, Min, tempsum)

 solve(m)
 println("m = ",getobjectivevalue(m))
 println("Aij = ", getvalue(aij))

but after operation, an error was shown as below.

MethodError: no method matching parseNLExpr_runtime(::JuMP.Model, ::JuMP.GenericQuadExpr{Float64,JuMP.Variable}, ::Array{ReverseDiffSparse.NodeData,1}, ::Int64, ::Array{Float64,1})

The error occurs on @NLobjective(m, Min, tempsum), but I dont know how to modify the code. May you please anyone help me ?

Besides, I am also confused by how to add positive definite contraints here for the solution Matrix aij, as I want to get a positive definite matrix aij.

Upvotes: 1

Views: 144

Answers (1)

Xentios
Xentios

Reputation: 80

@NLobjective(m, Min, tempsum) the tempsum in this code must be a function which is registered by Jump.register(***).

Upvotes: 0

Related Questions