Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indmax -> argmax #289

Merged
merged 1 commit into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/resolve/FieldValues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ Base.copy(a::FieldValue) = FieldValue(a.l0, copy(a.l1), copy(a.l2), a.l3)
# some hard constraint is being violated
validmax(a::FieldValue) = a.l0 >= 0

# like usual indmax, but favors the highest indices
# like usual argmax, but favors the highest indices
# in case of a tie
function Base.indmax(f::Field)
function Base.argmax(f::Field)
m = typemin(FieldValue)
mi = 0
for j = length(f):-1:1
Expand Down
4 changes: 2 additions & 2 deletions src/resolve/MaxSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function decimate1!(p0::Int, graph::Graph, strace::SolutionTrace, msgs::Messages
@assert solution[p0] == 0
@assert !graph.ignored[p0]
fld0 = fld[p0]
s0 = indmax(fld0)
s0 = argmax(fld0)
# only do the decimation if it is consistent with
# the constraints...
gconstr[p0][s0] || return 0
Expand Down Expand Up @@ -416,7 +416,7 @@ function converge!(graph::Graph, msgs::Messages, strace::SolutionTrace, perm::No
# pick the first decimation candidate
smx(p1) = secondmax(msgs.fld[p1], graph.gconstr[p1])
p0 = reduce((p1,p2)->(smx(p1)≤smx(p2) ? p1 : p2), findall(.!(graph.ignored)))
s0 = indmax(fld[p0])
s0 = argmax(fld[p0])
strace.staged = dec_firstcandidate(graph, msgs)
end
return false
Expand Down