Problems
import mathy_core.problems
Utility functions for helping generate input problems.
DefaultType¶
Template type for a default return value
gen_binomial_times_binomial¶
gen_binomial_times_binomial(
op: str = '+',
min_vars: int = 1,
max_vars: int = 2,
simple_variables: bool = True,
powers_probability: float = 0.33,
like_variables_probability: float = 1.0,
) -> Tuple[str, int]
Example
(2e + 12p)(16 + 7e)
gen_binomial_times_monomial¶
gen_binomial_times_monomial(
op: str = '+',
min_vars: int = 1,
max_vars: int = 2,
simple_variables: bool = True,
powers_probability: float = 0.33,
like_variables_probability: float = 1.0,
) -> Tuple[str, int]
Example
(4x^3 + y) * 2x
gen_combine_terms_in_place¶
gen_combine_terms_in_place(
min_terms: int = 16,
max_terms: int = 26,
easy: bool = True,
powers: bool = False,
) -> Tuple[str, int]
The problem is intended to be solved in a very small number of moves, making training across many episodes relatively quick, and reducing the combinatorial explosion of branches that need to be searched to solve the task.
The hope is that by focusing the agent on selecting the right moves inside of a ridiculously large expression it will learn to select actions to combine like terms invariant of the sequence length.
Example
4y + 12j + 73q + 19k + 13z + 56l + (24x + 12x) + 43n + 17j
gen_commute_haystack¶
gen_commute_haystack(
min_terms: int = 5,
max_terms: int = 8,
commute_blockers: int = 1,
easy: bool = True,
powers: bool = False,
) -> Tuple[str, int]
Example
4y + 12j + 73q + 19k + 13z + 24x + 56l + 12x + 43n + 17j"
^-----------^
gen_move_around_blockers_one¶
gen_move_around_blockers_one(
number_blockers: int,
powers_probability: float = 0.5,
) -> Tuple[str, int]
Example
4x + (y + f) + x
gen_move_around_blockers_two¶
gen_move_around_blockers_two(
number_blockers: int,
powers_probability: float = 0.5,
) -> Tuple[str, int]
Example
7a + 4x + (2f + j) + x + 3d
gen_simplify_multiple_terms¶
gen_simplify_multiple_terms(
num_terms: int,
optional_var: bool = False,
op: Optional[List[str], str] = None,
common_variables: bool = True,
inner_terms_scaling: float = 0.3,
powers_probability: float = 0.33,
optional_var_probability: float = 0.8,
noise_probability: float = 0.8,
shuffle_probability: float = 0.66,
share_var_probability: float = 0.5,
grouping_noise_probability: float = 0.66,
noise_terms: Optional[int] = None,
) -> Tuple[str, int]
Example
2a + 3j - 7b + 17.2a + j
get_blocker¶
get_blocker(
num_blockers: int = 1,
exclude_vars: Optional[List[str]] = None,
) -> str
get_rand_vars¶
get_rand_vars(
num_vars: int,
exclude_vars: Optional[List[str]] = None,
common_variables: bool = False,
) -> List[str]
MathyTermTemplate¶
MathyTermTemplate(
self,
variable: Optional[str] = None,
exponent: Optional[float, int] = None,
) -> None
split_in_two_random¶
split_in_two_random(value: int) -> Tuple[int, int]
use_pretty_numbers¶
use_pretty_numbers(enabled: bool = True) -> None
rand_number