pub struct SolutionDescriptor {
pub type_name: &'static str,
pub type_id: TypeId,
pub entity_descriptors: Vec<EntityDescriptor>,
pub problem_fact_descriptors: Vec<ProblemFactDescriptor>,
pub score_field: &'static str,
pub score_is_optional: bool,
/* private fields */
}Expand description
Describes a planning solution at runtime.
Contains metadata about:
- Entity types and their descriptors
- Problem fact types
- Score type
Fields§
§type_name: &'static strName of the solution type.
type_id: TypeIdTypeId of the solution type.
entity_descriptors: Vec<EntityDescriptor>Descriptors for all entity types in this solution.
problem_fact_descriptors: Vec<ProblemFactDescriptor>Descriptors for all problem fact types.
score_field: &'static strName of the score field.
score_is_optional: boolWhether the score type is Option<Score>.
Implementations§
Source§impl SolutionDescriptor
impl SolutionDescriptor
Sourcepub fn new(type_name: &'static str, type_id: TypeId) -> Self
pub fn new(type_name: &'static str, type_id: TypeId) -> Self
Creates an empty descriptor whose score lives in an optional score field.
Sourcepub fn with_entity(self, descriptor: EntityDescriptor) -> Self
pub fn with_entity(self, descriptor: EntityDescriptor) -> Self
Appends an entity descriptor and indexes it by TypeId (first
descriptor wins) and by logical ID.
Sourcepub fn with_problem_fact(self, descriptor: ProblemFactDescriptor) -> Self
pub fn with_problem_fact(self, descriptor: ProblemFactDescriptor) -> Self
Appends a problem fact descriptor.
Sourcepub fn with_score_field(self, field: &'static str) -> Self
pub fn with_score_field(self, field: &'static str) -> Self
Sets the name of the score field.
Sourcepub fn find_entity_descriptor(
&self,
type_name: &str,
) -> Option<&EntityDescriptor>
pub fn find_entity_descriptor( &self, type_name: &str, ) -> Option<&EntityDescriptor>
Finds an entity descriptor by type name.
Sourcepub fn find_entity_descriptor_by_type(
&self,
type_id: TypeId,
) -> Option<&EntityDescriptor>
pub fn find_entity_descriptor_by_type( &self, type_id: TypeId, ) -> Option<&EntityDescriptor>
Finds the first entity descriptor registered for type_id.
Sourcepub fn find_entity_descriptor_by_logical_id(
&self,
logical_id: EntityClassId,
) -> Option<&EntityDescriptor>
pub fn find_entity_descriptor_by_logical_id( &self, logical_id: EntityClassId, ) -> Option<&EntityDescriptor>
Finds the entity descriptor registered for a logical entity class ID.
Sourcepub fn entity_descriptor_index_by_logical_id(
&self,
logical_id: EntityClassId,
) -> Option<usize>
pub fn entity_descriptor_index_by_logical_id( &self, logical_id: EntityClassId, ) -> Option<usize>
Index of the entity descriptor registered for a logical entity class ID.
Sourcepub fn genuine_variable_descriptors(&self) -> Vec<&VariableDescriptor>
pub fn genuine_variable_descriptors(&self) -> Vec<&VariableDescriptor>
Collects the genuine variables of every entity type, in descriptor order.
Sourcepub fn shadow_variable_descriptors(&self) -> Vec<&VariableDescriptor>
pub fn shadow_variable_descriptors(&self) -> Vec<&VariableDescriptor>
Collects the shadow variables of every entity type, in descriptor order.
Sourcepub fn total_entity_count(&self, solution: &dyn Any) -> Option<usize>
pub fn total_entity_count(&self, solution: &dyn Any) -> Option<usize>
Returns the total number of entities across all entity collections.
Returns None if any entity descriptor lacks an extractor or the solution
type doesn’t match.
Sourcepub fn all_entity_refs(&self, solution: &dyn Any) -> Vec<(usize, EntityRef)>
pub fn all_entity_refs(&self, solution: &dyn Any) -> Vec<(usize, EntityRef)>
References to every entity in solution, each paired with its entity descriptor index.
Sourcepub fn for_each_entity<F>(&self, solution: &dyn Any, f: F)
pub fn for_each_entity<F>(&self, solution: &dyn Any, f: F)
Calls f(descriptor_index, entity_index, entity) for every entity;
entity types without an extractor are skipped.
Sourcepub fn get_entity<'a>(
&self,
solution: &'a dyn Any,
descriptor_index: usize,
entity_index: usize,
) -> Option<&'a dyn Any>
pub fn get_entity<'a>( &self, solution: &'a dyn Any, descriptor_index: usize, entity_index: usize, ) -> Option<&'a dyn Any>
Borrows one entity; None when either index is out of range, the
descriptor has no extractor, or the solution type does not match.
Sourcepub fn get_entity_mut<'a>(
&self,
solution: &'a mut dyn Any,
descriptor_index: usize,
entity_index: usize,
) -> Option<&'a mut dyn Any>
pub fn get_entity_mut<'a>( &self, solution: &'a mut dyn Any, descriptor_index: usize, entity_index: usize, ) -> Option<&'a mut dyn Any>
Mutably borrows one entity; None when either index is out of range,
the descriptor has no extractor, or the solution type does not match.
Sourcepub fn entity_descriptor_count(&self) -> usize
pub fn entity_descriptor_count(&self) -> usize
Number of entity descriptors.
Sourcepub fn problem_fact_descriptor_count(&self) -> usize
pub fn problem_fact_descriptor_count(&self) -> usize
Number of problem fact descriptors.
Sourcepub fn all_extractors_configured(&self) -> bool
pub fn all_extractors_configured(&self) -> bool
Returns true when every entity descriptor has an extractor.