Skip to content

Commit

Permalink
Merge pull request #191 from Tractables/loaded-dice
Browse files Browse the repository at this point in the history
Better parameter learning and inductive types
  • Loading branch information
rtjoa authored Jul 19, 2024
2 parents 9ceda87 + 38da216 commit dcd3406
Show file tree
Hide file tree
Showing 49 changed files with 1,367 additions and 2,454 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
run:
julia --project --check-bounds=yes --depwarn=yes -e 'import Pkg; Pkg.test(; coverage=true)'

- name: Codecov Upload
run:
julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder());'
# - name: Codecov Upload
# run:
# julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder());'
11 changes: 6 additions & 5 deletions examples/darts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ all(itr) = reduce(&, itr)
any(itr) = reduce(|, itr)

DARTS_PER_COLOR = [1, 2, 10] # number of red, green, and blue darts
weights = [var!("r", 1), var!("g", 1), var!("b", 1)]
weights = [Var("r"), Var("g"), Var("b")]
var_vals = Valuation(weight => 1 for weight in weights)

all_colors_receive_own_dart = all(
any(flip(weight / sum(weights)) for _ in 1:num_own_darts)
for (num_own_darts, weight) in zip(DARTS_PER_COLOR, weights)
)

pr(all_colors_receive_own_dart) # 0.182
train_vars!([all_colors_receive_own_dart]; epochs=1000, learning_rate=0.3)
pr_mixed(var_vals)(all_colors_receive_own_dart) # 0.182
train!(var_vals, -LogPr(all_colors_receive_own_dart); epochs=1000, learning_rate=0.3)

# We've increased the chance of success!
pr(all_colors_receive_own_dart) # 0.234
pr_mixed(var_vals)(pr_all_colors_receive_own_dart) # 0.234

# Compute what ratio we actually need to paint the target:
[compute(weight/sum(weights)) for weight in weights]
[compute(var_vals, weight/sum(weights)) for weight in weights]
# 3-element Vector{Float64}:
# 0.46536681058883267
# 0.3623861813855715
Expand Down
19 changes: 0 additions & 19 deletions examples/qc/README.md

This file was deleted.

105 changes: 0 additions & 105 deletions examples/qc/demo_bst.jl

This file was deleted.

68 changes: 0 additions & 68 deletions examples/qc/demo_natlist.jl

This file was deleted.

113 changes: 0 additions & 113 deletions examples/qc/demo_sortednatlist.jl

This file was deleted.

Loading

0 comments on commit dcd3406

Please sign in to comment.