Skip to content

Commit d3d2eac

Browse files
Merge pull request #15 from MatthewStuber/FIxedTape
Minor update to fixed tape methods.
2 parents e23b2b8 + 69dc45e commit d3d2eac

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

example/DAGcontractor.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ tapelist_out = Generate_TapeList(mult_expr,5,[-1.0,2.0],[2.0,3.0])
1919
X = [Interval(0.5,10.0) for i=1:5]
2020
DAGContractor!(X,tapelist_out,6)
2121
println("contracted X value: ", X)
22+
23+
#=
24+
generates the tape list for the constraints -1 <= (x[1]+x[2]^2-exp(x[1]) <= 2
25+
and 2 <= :(x[1]*x[2]-x[5]) <= 4 with x[5]==5 and runs the contractor 6 times in place on the
26+
variable box X = [1,20]^5
27+
=#
28+
29+
X = [Interval(-10.0,10.0) for i=1:5]
30+
ftapelist_out = Generate_Fixed_TapeList(mult_expr,4,[-8.0,0.5],[2.0,4.5],[[5.0]])
31+
DAGContractor!(X,ftapelist_out,6)
32+
println("contracted X value: ", X)

src/src/FBBT/DAGprop.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ immutable Tape
4949
gU::Float64
5050
cnsts::Vector
5151
fix_val
52-
fix_ind
5352
end
5453

5554
"""
@@ -69,7 +68,6 @@ Tape() = ([],
6968
0.0,
7069
0.0,
7170
[],
72-
[],
7371
[])
7472

7573
"""
@@ -113,7 +111,7 @@ function Generate_Tape(exp::Expr,nx::Int64,gL,gU)
113111
NodeCounter,Interval[Interval(-Inf,Inf) for i=1:NodeCounter],
114112
FW_Arg,[Expr(:call) for i=1:NodeCounter],nx,
115113
RW_Arg,[Expr(:call) for i=1:NodeCounter],gL,gU,
116-
deepcopy(ConstList),[],[])
114+
deepcopy(ConstList),[])
117115
global EdgeList = []
118116
global HeaderList = Symbol[]
119117
global ConstList = []
@@ -135,7 +133,7 @@ function Generate_Fixed_Tape(exp::Expr,nx::Int64,gL,gU,vals)
135133
# Sets up node finding object and generates graph to global
136134
X_NodeF::Vector{Any} = vcat(Any[NodeFinder(i) for i=1:nx],vals)
137135
global NodeCounter = deepcopy(nx)
138-
fX! = @eval x::Vector{NodeFinder} -> $exp
136+
fX! = @eval x::Vector{Any} -> $exp
139137
Base.invokelatest(fX!,X_NodeF)
140138

141139
# generates forward tape
@@ -295,10 +293,11 @@ and the initial interval bounds `X::Vector{Interval{T}}`.
295293
function DAGContractor!(X::Vector{Interval{T}},x::TapeList,r) where {T}
296294
Xprev::Vector{Interval} = copy(X) # sets variable bounds on first Array to Box Bounds
297295
SetConstraintNode!(x)
298-
SetConstantNode!(x)
296+
#SetConstantNode!(x)
299297
for i=1:r
300298
for j=1:length(x.sto)
301299
SetVarBounds!(x.sto[j],Xprev) # take refined bounds from previous graph
300+
SetConstantNode!(x)
302301
ForwardPass!(x.sto[j]) # run forward and reverse pass
303302
ReversePass!(x.sto[j])
304303
Xprev = x.sto[j].Intv_Storage[1:length(X)]

0 commit comments

Comments
 (0)