Skip to content

Commit

Permalink
Fix AppVeyor build
Browse files Browse the repository at this point in the history
  • Loading branch information
IainNZ committed Sep 27, 2014
1 parent 09fde0e commit bbaa215
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 25 deletions.
71 changes: 59 additions & 12 deletions test/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,57 @@ function test_print_JuMPContainerVal()
println(" test_print_JuMPContainerVal")

mod = Model()
@defVar(mod, i*j <= w[i=9:10, [:Apple,5,:Banana], j=-1:+1] <= i*j)
@defVar(mod, i*j*k <= x[i=9:11,j=99:101,k=3:4] <= i*j*k)
@defVar(mod, i*j <= y[i=9:11,j=i:11] <= i*j)
@defVar(mod, j <= z[i=[:a,"b",'c'],j=1:3] <= j)
@defVar(mod, j <= z[i=[:a,'b'],j=1:3] <= j)
solve(mod)

# Deal with hashing variations
if hash(5) < hash(:Apple)
io_test(REPLMode, getValue(w), """
w: 3 dimensions, 18 entries:
[9,5,-1] = -9.0
[9,5,0] = 0.0
[9,5,1] = 9.0
[9,Apple,-1] = -9.0
[9,Apple,0] = 0.0
[9,Apple,1] = 9.0
[9,Banana,-1] = -9.0
[9,Banana,0] = 0.0
[9,Banana,1] = 9.0
[10,5,-1] = -10.0
[10,5,0] = 0.0
[10,5,1] = 10.0
[10,Apple,-1] = -10.0
[10,Apple,0] = 0.0
[10,Apple,1] = 10.0
[10,Banana,-1] = -10.0
[10,Banana,0] = 0.0
[10,Banana,1] = 10.0""", repl=:print)

This comment has been minimized.

Copy link
@joehuchette

joehuchette Sep 27, 2014

Contributor

It'd be cool to align indices in each dimension, so you can just scan down a single column.

This comment has been minimized.

Copy link
@IainNZ

IainNZ Sep 27, 2014

Author Collaborator

Thats true - the code I wrote for JuMPArrays does that. I'm kinda itching to merge it into master so I think I'll address that later.

This comment has been minimized.

Copy link
@joehuchette

joehuchette Sep 27, 2014

Contributor

I went ahead and implemented it, though it's probably not as performant as it should be (lots of anonymous functions and copying strings). Feel free to go ahead and merge, I can always add it in later.

else
io_test(REPLMode, getValue(w), """
w: 3 dimensions, 18 entries:
[9,Apple,-1] = -9.0
[9,Apple,0] = 0.0
[9,Apple,1] = 9.0
[9,Banana,-1] = -9.0
[9,Banana,0] = 0.0
[9,Banana,1] = 9.0
[9,5,-1] = -9.0
[9,5,0] = 0.0
[9,5,1] = 9.0
[10,Apple,-1] = -10.0
[10,Apple,0] = 0.0
[10,Apple,1] = 10.0
[10,Banana,-1] = -10.0
[10,Banana,0] = 0.0
[10,Banana,1] = 10.0
[10,5,-1] = -10.0
[10,5,0] = 0.0
[10,5,1] = 10.0""", repl=:print)
end

io_test(REPLMode, getValue(x), """
[ 9,:,:]
[ 9, 99,:]
Expand Down Expand Up @@ -244,18 +290,19 @@ y: 2 dimensions, 6 entries:
[10,10] = 100.0
[10,11] = 110.0
[11,11] = 121.0""", repl=:print)


# Deal with hashing variations
first_hash = hash(:a) < hash('b') ? "a" : "b"
second_hash = first_hash == "a" ? "b" : "a"
io_test(REPLMode, getValue(z), """
z: 2 dimensions, 9 entries:
[a,1] = 1.0
[a,2] = 2.0
[a,3] = 3.0
[b,1] = 1.0
[b,2] = 2.0
[b,3] = 3.0
[c,1] = 1.0
[c,2] = 2.0
[c,3] = 3.0""", repl=:print)
z: 2 dimensions, 6 entries:
[$first_hash,1] = 1.0
[$first_hash,2] = 2.0
[$first_hash,3] = 3.0
[$second_hash,1] = 1.0
[$second_hash,2] = 2.0
[$second_hash,3] = 3.0""", repl=:print)

end


Expand Down
13 changes: 0 additions & 13 deletions test/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ setUpper(x, 3)
@test getLower(y) == 0
@test getUpper(y) == 1

# Test printing of getValue(JuMPDict{Float64})
valmod = Model()
@defVar(valmod, i*j <= foobar[i=9:10, [:Apple,5,:Banana], j=-1:+1] <= i*j)
solve(valmod)
buf = IOBuffer()
println(buf, getValue(foobar))
result = takebuf_string(buf)
#if hash(5) < hash(:Apple) # hashing is different on some platforms, affects output order
# @test result == "3-dimensional JuMPDict with 18 entries:\n foobar[9,5,-1] = -9.0\n foobar[9,5,0] = 0.0\n foobar[9,5,1] = 9.0\n foobar[9,Apple,-1] = -9.0\n foobar[9,Apple,0] = 0.0\n foobar[9,Apple,1] = 9.0\n foobar[9,Banana,-1] = -9.0\n foobar[9,Banana,0] = 0.0\n foobar[9,Banana,1] = 9.0\n foobar[10,5,-1] = -10.0\n foobar[10,5,0] = 0.0\n foobar[10,5,1] = 10.0\n foobar[10,Apple,-1] = -10.0\n foobar[10,Apple,0] = 0.0\n foobar[10,Apple,1] = 10.0\n foobar[10,Banana,-1] = -10.0\n foobar[10,Banana,0] = 0.0\n foobar[10,Banana,1] = 10.0\n"
#else
# @test result == "3-dimensional JuMPDict with 18 entries:\n foobar[9,Apple,-1] = -9.0\n foobar[9,Apple,0] = 0.0\n foobar[9,Apple,1] = 9.0\n foobar[9,Banana,-1] = -9.0\n foobar[9,Banana,0] = 0.0\n foobar[9,Banana,1] = 9.0\n foobar[9,5,-1] = -9.0\n foobar[9,5,0] = 0.0\n foobar[9,5,1] = 9.0\n foobar[10,Apple,-1] = -10.0\n foobar[10,Apple,0] = 0.0\n foobar[10,Apple,1] = 10.0\n foobar[10,Banana,-1] = -10.0\n foobar[10,Banana,0] = 0.0\n foobar[10,Banana,1] = 10.0\n foobar[10,5,-1] = -10.0\n foobar[10,5,0] = 0.0\n foobar[10,5,1] = 10.0\n"
#end

# Repeated elements in index set (issue #199)
repeatmod = Model()
s = [:x,:x,:y]
Expand Down

0 comments on commit bbaa215

Please sign in to comment.