Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chkwon committed Apr 30, 2016
1 parent d1a63de commit 8700718
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 0 additions & 2 deletions example/nagurney.jl
Expand Up @@ -3,8 +3,6 @@ using JuMP, VariationalInequality
# include("../src/algorithms.jl")

using Base.Test
using FactCheck



# https://supernet.isenberg.umass.edu/articles/SPE_Model_Information_Asymmetry_in_Quality.pdf
Expand Down
8 changes: 8 additions & 0 deletions src/model.jl
Expand Up @@ -40,6 +40,14 @@ function correspond(m::Model, expressions::Array{JuMP.NonlinearExpression}, vari
end
end

function correspond(m::Model, expressions::JuMP.JuMPArray, variables::JuMP.JuMPArray)
variables = collect(variables.innerArray)
expressions = collect(expressions.innerArray)
@assert length(expressions) == length(variables)
for i in 1:length(variables)
correspond(m, expressions[i], variables[i])
end
end

# function setVIP(m::Model, expressions::Array{JuMP.NonlinearExpression,1}, variables::Array{JuMP.Variable,1})
# @assert length(expressions) == length(variables)
Expand Down
30 changes: 30 additions & 0 deletions test/test.jl
@@ -0,0 +1,30 @@

using JuMP
import MathProgBase




m = Model()
@defVar(m, x1)
@addNLConstraint(m, cons1, x1^2 <= 1)
@addNLConstraint(m, cons2, x1^2 >= 2)
@addNLConstraint(m, cons2, x1^2 == 2)
z = [1.0]

d = JuMPNLPEvaluator(m)
MathProgBase.initialize(d, [:Grad])

g_val= zeros(3)
MathProgBase.eval_g(d, g_val, z)
@show g_val

I,J = MathProgBase.jac_structure(d)
jac_val = zeros(size(J))
MathProgBase.eval_jac_g(d, jac_val, z)
jac = full(sparse(I, J, jac_val))
@show jac

lb_consts, ub_consts = JuMP.getConstraintBounds(m)

println("----")

0 comments on commit 8700718

Please sign in to comment.