Small clean up

This commit is contained in:
2021-10-27 15:31:15 +02:00
parent 71b795d9ed
commit 9307c36282
2 changed files with 30 additions and 7 deletions

View File

@@ -1,20 +1,23 @@
extern crate blas_src; extern crate blas_src;
use kickscore as ks; use kickscore::{
kernel::{self, Kernel},
model::{binary, Binary},
};
fn main() { fn main() {
let mut model = ks::model::Binary::new(ks::model::binary::Observation::Probit); let mut model = Binary::new(binary::Observation::Probit);
// Spike's skill does not change over time. // Spike's skill does not change over time.
let k_spike = ks::kernel::Constant::new(0.5); let k_spike = kernel::Constant::new(0.5);
// Tom's skill changes over time, with "jagged" (non-smooth) dynamics. // Tom's skill changes over time, with "jagged" (non-smooth) dynamics.
let k_tom = ks::kernel::Exponential::new(1.0, 1.0); let k_tom = kernel::Exponential::new(1.0, 1.0);
// Jerry's skill has a constant offset and smooth dynamics. // Jerry's skill has a constant offset and smooth dynamics.
let k_jerry: [Box<dyn ks::Kernel>; 2] = [ let k_jerry: [Box<dyn Kernel>; 2] = [
Box::new(ks::kernel::Constant::new(1.0)), Box::new(kernel::Constant::new(1.0)),
Box::new(ks::kernel::Matern52::new(0.5, 1.0)), Box::new(kernel::Matern52::new(0.5, 1.0)),
]; ];
// Now we are ready to add the items in the model. // Now we are ready to add the items in the model.

View File

@@ -2,6 +2,26 @@ use std::collections::HashMap;
use crate::item::Item; use crate::item::Item;
/*
pub trait Storage {
type Key;
type IterKeys:
type IterItems:
type IterItemsMut:
fn contains_key(&self, key: Self::Key) -> bool;
fn insert(&mut self, key: Self::Key, item: Item);
fn get_id(&self, key: Self::Key) -> usize;
fn get_item(&mut self, id: usize) -> &mut Item;
fn item(&self, id: usize) -> &Item;
fn item_mut(&mut self, id: usize) -> &mut Item;
fn items(&self) -> impl Iterator<Item = &Item>;
fn items_mut(&mut self) -> impl Iterator<Item = &mut Item>;
fn keys(&self) -> impl Iterator<Item = &String>;
}
*/
pub struct Storage { pub struct Storage {
keys: HashMap<String, usize>, keys: HashMap<String, usize>,
items: Vec<Item>, items: Vec<Item>,