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

FEAT: Add tol option to best response related methods #74

Merged
merged 6 commits into from
Mar 9, 2018
Merged

Conversation

QBatista
Copy link
Member

@QBatista QBatista commented Mar 7, 2018

Close #21 #75

@oyamad
Copy link
Member

oyamad commented Mar 7, 2018


# Returns
- `ne::Vector{NTuple{N,Int}}`: Vector of pure action Nash equilibria.
"""
function pure_nash(nfg::NormalFormGame; ntofind=Inf)
function pure_nash(nfg::NormalFormGame; ntofind=Inf, tol::Float64=1e-8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tol is not used in is_nash!

@codecov-io
Copy link

codecov-io commented Mar 7, 2018

Codecov Report

Merging #74 into master will increase coverage by 0.87%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
+ Coverage   94.28%   95.15%   +0.87%     
==========================================
  Files           5        5              
  Lines         350      351       +1     
==========================================
+ Hits          330      334       +4     
+ Misses         20       17       -3
Impacted Files Coverage Δ
src/normal_form_game.jl 94.87% <100%> (+2.63%) ⬆️
src/pure_nash.jl 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b47bc1b...d1387f6. Read the comment docs.

@coveralls
Copy link

coveralls commented Mar 7, 2018

Coverage Status

Coverage increased (+0.9%) to 95.157% when pulling d1387f6 on tol_option into b47bc1b on master.

@oyamad oyamad mentioned this pull request Mar 8, 2018
@@ -306,7 +306,7 @@ end
"""
best_response(player, opponents_actions, payoff_perturbation)

Return the perturbed best response to `opponents_actions`.
Return the perturbed best responses to `opponents_actions`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be singular?

throw(ArgumentError(
"tie_breaking must be one of 'smallest' or 'random'"
))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need these tie_breaking and tol for this method. payoff_perturbation is supposed to break ties (assuming that perturbations are drawn from some continuous distribution).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this to match the Python version which has both. Do you want me to get rid of it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.


# Returns

- `::Bool`
"""
is_nash(g::NormalFormGame{1}, action::Action) =
is_best_response(g.players[1], action, nothing)
is_nash(g::NormalFormGame{1}, action::Action, tol::Float64=1e-8) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tol must be a keyword argument.

is_nash(g::NormalFormGame{1}, action::Action, tol::Float64=1e-8) =
is_best_response(g.players[1], action, nothing, tol=tol)

is_nash(g::NormalFormGame{1}, action_profile::ActionProfile) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tol argument.

@QBatista
Copy link
Member Author

QBatista commented Mar 9, 2018

@oyamad This should be ready -- do you want me to squash into a few logical commits before reviewing it?

@oyamad
Copy link
Member

oyamad commented Mar 9, 2018

Yes, please.

Copy link
Member

@oyamad oyamad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

I added one more small test.

@oyamad oyamad merged commit 667ea37 into master Mar 9, 2018
@oyamad oyamad deleted the tol_option branch March 9, 2018 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants