Code Monkey home page Code Monkey logo

doublequack.jl's Introduction

DoubleQuack.jl

IPopt double-oracle.

Install

Install the package directly from Github.

]add https://github.com/votroto/DoubleQuack.jl.git

Example 1: Find a mixed strategy

function run_experiment_solve(p, ds, vs; iterations)
    quack = DoubleQuack.quack_oracle(p, ds, vs)
    pure, prob, _ = DoubleQuack.fixed_iters(quack, iterations)

    pure, prob
end

@variables x[1:6]

payoff = sum(x[i] + x[3+i] for i in 1:3) - prod((x[i] - x[3+i]) for i in 1:3)

dom1 = (x[1]^2  1, x[2]^2  1, x[3]^2  1)
dom2 = (x[4]^2  1, x[5]^2  1, x[6]^2  1,)
domains = (dom1, dom2)

variables = ((x[1], x[2], x[3]), (x[4], x[5], x[6]))

pure, prob = run_experiment_solve(-payoff, domains, variables; iterations=15)

Results in

Player 1 - Centered at (-0.333, -0.333, -0.333):
      33.3% (1.0, -1.0, -1.0)
      33.3% (-1.0, 1.0, -1.0)
      33.3% (-1.0, -1.0, 1.0)

Player 2 - Centered at (1.0, 1.0, 1.0):
     100.0% (1.0, 1.0, 1.0)

Example 2: Exploitability sequence

function run_experiment_exploit(p, ds, vs; iterations)
    quack = DoubleQuack.quack_oracle(p, ds, vs)

    exploit = Array{Float64}(undef, iterations)
    iter = 1
    for (_, _, _, best) in take(quack, iterations)
        exploit[iter] = sum(best)
        iter += 1
    end

    exploit
end

@variables x y

payoff = 5*x*y-2x^2-2*x*y^2-y
doms = ((x^2 ≲ 1,), (y^2 ≲ 1,))
vars = ((x,), (y,))

es = run_experiment_exploit(payoff, doms, vars; iterations=10)

Results in

1.000
1.125
1.615
0.070
0.018
0.004
0.001
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

doublequack.jl's People

Contributors

votroto avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.