ClassificationTaskKind
RL4CRN.utils.default_tasks.ClassificationTaskKind
ClassificationTaskKind
Bases: TaskKindBase
Classification task: map initial condition -> desired output class trajectory.
Required params
ic_r_maps: List of (ic_values_block, r_value) where: - ic_values_block is List[List[float]] of ICs - r_value is List[float] (class vector), repeated for each IC in the block u_list: Constant input(s) applied during simulation (usually a single value for 1-input CRNs) t_f, n_t: Time horizon definition.
Reward
dynamic_tracking_error(state, u_list, x0_list, time_horizon, r_list, w, ...)
default_u_list(task)
Fallback u_list if user does not provide one. For 1-input CRNs, defaults to [1.0]. For multi-input, defaults to all-ones.
pretty_help(*, width=100, bullet='-', return_str=False)
classmethod
Pretty-print the task-kind help specification in a Markdown-like list format.
This uses cls.help() (a static method implemented by each TaskKind).
The expected shape is:
{
"required": {<key>: <description>, ...},
"optional": {<key>: <description>, ...},
"notes": <string or list of strings>
}
| PARAMETER | DESCRIPTION |
|---|---|
width
|
Maximum line width for wrapping descriptions.
TYPE:
|
bullet
|
Bullet marker to use for list items (default "-").
TYPE:
|
return_str
|
If True, return the formatted string instead of printing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[str]
|
If return_str=True, returns the formatted help string. Otherwise None. |
build_time_horizon(task)
Build or reuse the time horizon.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
TaskSpec instance.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Time grid array of shape (n_t,) float32. |
build_u_list(task, overrides)
Build or override the u_list for evaluation.
Precedence
overrides['u_list'] overrides['u_spec'] task.u_list (if user provided explicit list) task.u_spec (special tags only) TaskKind.default_u_list(task) # kind-specific semantics
| PARAMETER | DESCRIPTION |
|---|---|
task
|
TaskSpec instance.
TYPE:
|
overrides
|
Override dictionary.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[ndarray]
|
List of input vectors (float32 arrays), each shape (p,). |
build_ic(task, overrides)
Build the IC object from spec or override.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
TaskSpec instance.
TYPE:
|
overrides
|
Override dictionary, may contain 'ic_spec'.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
RL4CRN IC object. |
build_weights(task, overrides)
Build weights if needed by the task kind.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
TaskSpec instance.
TYPE:
|
overrides
|
Override dictionary, may contain 'weights_spec'.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[ndarray]
|
Weight matrix or None. |
ic_builder_from_list(species_labels, ic_values)
Build a minimal IC object compatible with RL4CRN's TaskKind interface.
Parameters
species_labels: Names of the CRN species (used only for validation / record keeping). ic_values: List of initial-condition vectors, one per classification example.
Returns
obj
Object exposing get_ic(state) -> List[np.ndarray].