mod bounded;
mod dict;
mod discrete;
pub mod flatten;
mod graph;
mod multi_binary;
mod multi_discrete;
mod one_of;
mod sequence;
mod text;
mod tuple;
pub use bounded::BoundedSpace;
pub use dict::{AnySpace, AnyValue, DictSpace};
pub use discrete::Discrete;
pub use graph::{GraphInstance, GraphSpace};
pub use multi_binary::MultiBinary;
pub use multi_discrete::MultiDiscrete;
pub use one_of::OneOf;
pub use sequence::SequenceSpace;
pub use text::TextSpace;
pub use tuple::{Tuple2, Tuple3};
use crate::rng::Rng;
#[derive(Debug, Clone, PartialEq)]
pub enum SpaceInfo {
Discrete {
n: u64,
start: i64,
},
Bounded {
low: Vec<f32>,
high: Vec<f32>,
shape: Vec<usize>,
},
MultiDiscrete {
nvec: Vec<u64>,
},
MultiBinary {
n: usize,
},
Tuple(Vec<Self>),
Dict(Vec<(String, Self)>),
OneOf(Vec<Self>),
Sequence(Box<Self>),
Graph {
node_space: Box<Self>,
edge_space: Option<Box<Self>>,
},
Text {
min_length: usize,
max_length: usize,
},
}
pub trait Space {
type Element;
fn sample(&self, rng: &mut Rng) -> Self::Element;
fn contains(&self, value: &Self::Element) -> bool;
fn shape(&self) -> &[usize];
fn flatdim(&self) -> usize;
fn is_flattenable(&self) -> bool {
true
}
fn space_info(&self) -> SpaceInfo;
}