Browse Source

Add assertions on probability distribution

master
Forest Belton 3 years ago
parent
commit
d75e2458ed
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      gbso/optimize.py

+ 5
- 3
gbso/optimize.py View File

@ -1,8 +1,7 @@
from random import random
from typing import List, Tuple, TypeVar
from gbso.program.program import Program
EPSILON = 0.00001
DEFAULT_NUM_ITERS = 1_000_000
DEFAULT_PROB_OPCODE = 0.25
@ -22,4 +21,7 @@ def optimize(
prob_insn: float = DEFAULT_PROB_INSN,
prob_insn_unused: float = DEFAULT_PROB_INSN_UNUSED,
) -> Program:
prob_sum = sum([prob_opcode, prob_operand, prob_swap, prob_insn])
assert abs(1 - prob_sum) < EPSILON
return prgm

Loading…
Cancel
Save