brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
toolkitBuild, encode, decode, sample, inspect, optimize, and reload PhySO symbolic programs without running SR orchestration.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this sub-skill for the low-level symbolic-expression layer of PhySO. It
turns a token library and prefix expressions into executable Program or
VectPrograms objects, and provides safe routes for sampling, inspecting,
optimizing, displaying, and reloading those objects. The verified baseline is
PhySO 1.2.0 in a CPU-only Python environment. Import-time warnings about
missing system LaTeX are expected and do not invalidate plain-text workflows.
physo.toolkit.get_library, get_expressions, get_prior, and
sample_random_expressions.Library.encode/decode, prefix-token validation, one-hot encodings, and
length/structural priors.Dataset, Token and its public typed subclasses, Library, Program,
VectPrograms, Cursor, FreeConstantsTable, and differentiable
candidate_wrapper usage at the expression layer.RunLogger, Pareto-front inspection, physo.read_pareto_csv,
physo.read_pareto_pkl, and physo.load_expr.physo.SR and physo.ClassSR orchestration, run presets, stopping rules,
and dataset/task selection. Route those questions to
the SR sibling or the Class SR sibling.| Need | Start here | Result |
|---|---|---|
| Define variables, constants, operations, units, and free constants | physo.toolkit.get_library(...) | A physo.physym.library.Library |
| Encode readable prefix names | library.encode(expressions_str, one_hot=False) | One integer-token list per expression; one_hot=True returns one-hot matrices |
| Decode integer prefixes | library.decode(expressions_idx, n_realizations=1) | A VectPrograms batch with padded invalid placeholders |
| Make an empty program batch | physo.toolkit.get_expressions(batch_size, max_length, library, ...) | A VectPrograms ready for append or set_programs |
| Build priors for an existing batch | physo.toolkit.get_prior(priors_config, max_length, expressions, library) | A prior collection callable |
| Generate random valid candidates | physo.toolkit.sample_random_expressions(...) | A sampled VectPrograms batch |
| Inspect one candidate | batch.get_prog(i) | A Program with execution, constants, text, SymPy, and save methods |
| Inspect a batch/tree | batch.status(), batch.tokens, Cursor, family methods | Names, arities, units, parent/child/sibling/ancestor relations |
| Fit constants | program.optimize_constants(...), batch.batch_optimize_constants(...) | Updated constant tables and a loss history for the single-program route |
| Reload results | physo.read_pareto_pkl, physo.read_pareto_csv, physo.load_expr | Programs or SymPy expressions, subject to the CSV/Class SR caveat |
See API reference for source-verified signatures, workflows for compact recipes, and the PhySO root skill for install/backend routing.
X with shape
(n_dim, n_samples) and y with shape (n_samples,), both floating-point
tensors or safely convertible arrays. A Dataset receives lists
multi_X and multi_y, even for one realization ([X], [y]). Keep all
X, y, and weights on the same device.X_names, y_name, aligned fixed and
free-constant arrays, and an explicit op_names list. Use protected
operations unless you deliberately need unprotected numerical behavior.
With units, every terminal units vector must be aligned and consistent.['mul', 'c', 'x']. Check library.choosable_names; placeholders such as
the superparent, dummy, and invalid token are not encodable user tokens.int indices to
Library.decode. Inspect batch.status(), batch.n_lengths,
batch.is_complete, and batch.get_infix_str(i) before executing. A prefix
expression must be a complete tree: len(tokens) - sum(token.arity) == 1.batch_size and max_length
for exploration. If priors_config is supplied, include a
HardLengthPrior; its max_length controls the sampler and takes
precedence over the top-level value. Seed NumPy and PyTorch when a
reproducible fixture matters.Program with get_prog, call it with a
tensor, or use execute(..., i_realization=..., n_samples_per_dataset=...)
for realization-specific constants. Prefer get_infix_str,
get_infix_pretty, and get_infix_sympy for non-graph output.candidate_wrapper, it
must be callable as (func, X) -> wrapped_output and remain differentiable.
Program.optimize_constants uses
MSE plus LBFGS by default; inspect history, free_consts.class_values,
free_consts.spe_values, is_opti, and opti_steps.latex,
pygraphviz, dot2tex, pdflatex, pdf2image, or Pillow affects images
and tree rendering, not prefix encoding or plain text. Do not turn a display
dependency into a core-workflow failure.X_names length must match the first dimension of data;
units rows must align with their names and use at most seven dimensions.
fixed_consts_units, free_consts_units, and spe-constant units align with
their corresponding value/name arrays. For the toolkit convenience API,
free_consts_init_val and spe_free_consts_init_val are array-like values
aligned with names; low-level tokenization may use name-to-value dicts.encode, or Python integers for decode.
Variable expression lengths are accepted by decode and padded internally.
One-hot output is for model input and is not a valid direct input to
decode.X is (n_dim, n_samples), target and weights are
(n_samples,). For flattened multiple realizations, concatenate datasets in
realization order and pass n_samples_per_dataset with the matching counts.class_values has shape
(batch_size, n_class_free_const); spe_values has shape
(batch_size, n_spe_free_const, n_realizations). A scalar spe initializer is
broadcast; a vector must have exactly n_realizations entries.RunLogger.get_pareto_front() returns
(complexities, programs, rewards, rmse). read_pareto_pkl returns a list
of Program objects; read_pareto_csv returns SymPy expressions, or a
(expressions, DataFrame) tuple when return_df=True.The related native candidates are:
physo.toolkit.tests.codec_UnitTestphyso.toolkit.tests.random_sampler_UnitTestphyso.physym.tests.program_UnitTestphyso.physym.tests.vect_programs_UnitTestphyso.physym.tests.library_UnitTestphyso.physym.tests.token_UnitTestphyso.physym.tests.tokenize_UnitTestphyso.physym.tests.dataset_UnitTestphyso.physym.tests.free_const_UnitTestphyso.physym.tests.program_display_UnitTestphyso.learn.tests.monitoring_UnitTestRun the bundled CPU-safe checks before using a generated result:
python skills/disco/physo/sub-skills/toolkit/scripts/check_toolkit_roundtrip.py
python skills/disco/physo/sub-skills/toolkit/scripts/smoke_toolkit.py
These scripts do not access the network, plot, or launch a long search. They
exercise encoding/decoding, an expected unknown-token failure, bounded random
sampling, Dataset shape handling, and a small LBFGS constant fit.
Use troubleshooting when an error is not immediately explained. In particular, check exact library names and token arity before changing code; check spe initializer and flattened-data shapes before changing an optimizer; and use text/SymPy output before installing optional renderers. If the request asks for an SR/Class SR run or a benchmark problem loader, hand it to the sibling skill instead of extending this route.