pub struct Actions<T: Caller> {
pub caller: T,
}
Fields§
§caller: T
Implementations§
Source§impl<T: Caller> Actions<T>
impl<T: Caller> Actions<T>
Sourcepub fn gmp(
&self,
population: u32,
allowed_groups: Vec<u32>,
) -> T::ReturnType<Option<Vec<u32>>>
pub fn gmp( &self, population: u32, allowed_groups: Vec<u32>, ) -> T::ReturnType<Option<Vec<u32>>>
This action runs an algorithm that could be called, “greatest minimum partition”.
It returns a vector of subgroupings that sum to the total population, where each subgrouping has a size that is allowed by the allowed_groups parameter, and with a grouping preference that maximizes the size of the smallest subgroup.
For example, with a population of size 10, and allowed_groups = [4,5,6], one valid way to construct groups would be: [4, 6]. But the optimal way according to this algorithm would be: [5,5]. This is because the minimum partition in the first case is 4, and in the second case it is 5, and this algorithm tries to find the greatest minimum partition.
Parameters:
population
- The total population to partitionallowed_groups
- A vector of allowed group sizes
Returns:
Some(Vec<u32>)
- A valid partition of the population into allowed group sizes.None
- No valid partition exists
Trait Implementations§
Source§impl<T: Caller> ToActionsSchema for Actions<T>
impl<T: Caller> ToActionsSchema for Actions<T>
fn to_schema( builder: &mut SchemaBuilder, ) -> IndexMap<MethodString, FunctionType>
Auto Trait Implementations§
impl<T> Freeze for Actions<T>where
T: Freeze,
impl<T> RefUnwindSafe for Actions<T>where
T: RefUnwindSafe,
impl<T> Send for Actions<T>where
T: Send,
impl<T> Sync for Actions<T>where
T: Sync,
impl<T> Unpin for Actions<T>where
T: Unpin,
impl<T> UnwindSafe for Actions<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more