Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semiring Applications - All pairs shortest path (Tropical semiring) + Ridge Linear Regression (Semiring) #1221

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
24b8d90
part 1
chaeyeonlee07 May 2, 2024
ac7d0a0
editted semiring and added test
chaeyeonlee07 May 13, 2024
bdca8ca
editted semiring and added test
chaeyeonlee07 May 13, 2024
d791360
testing if this passes test
chaeyeonlee07 May 16, 2024
b36b83d
edit1
chaeyeonlee07 May 16, 2024
d68810f
fixed lint errors by adding allow dead code
chaeyeonlee07 May 17, 2024
8f89582
local lint test was passing but it wasn't ongithub so fixed
chaeyeonlee07 May 17, 2024
77514e5
fixed lib rs to fit the standard structure of lattice
chaeyeonlee07 May 17, 2024
b871d6e
changed lib rs so that semiring functions matches the structure of la…
chaeyeonlee07 May 17, 2024
8c838d7
test(semiring applications): added semiring applications and their co…
chaeyeonlee07 May 17, 2024
ab6b69e
Merge branch 'main' into semiring_application
chaeyeonlee07 May 17, 2024
86cb3a8
feat(semiring_applications): added all pair shortest path (APSP) algo…
chaeyeonlee07 May 22, 2024
5ac169f
feat(semiring_applications): added APSP (all pairs shortest path) alg…
chaeyeonlee07 May 22, 2024
581bb32
feat(semiring_applications): changed the format of all-pairs-shortest…
chaeyeonlee07 May 28, 2024
2e517b0
feat: added ridge regression implementation and its corresponding tests.
chaeyeonlee07 Jun 6, 2024
e104619
feat(group_application): added zset group aggregation example
chaeyeonlee07 Jun 10, 2024
51b025d
feat(group_application): zset examples and their test.
chaeyeonlee07 Jun 10, 2024
a072b38
added new tests for apsp and commented out ridge regression tests
Sep 13, 2024
4767006
feat(semiring application): fixed apsp to take in a list of tuples in…
Sep 18, 2024
bad2a52
Resolving Comment
Oct 9, 2024
da2b1d5
Merging
Oct 9, 2024
b2c7267
Revert "feat(semiring application): fixed apsp to take in a list of t…
Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions lattices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod map_union_with_tombstones;
mod ord;
mod pair;
mod point;
pub mod semiring_application;
pub mod set_union;
pub mod set_union_with_tombstones;
pub mod test;
Expand All @@ -40,6 +41,51 @@ pub trait Lattice: Sized + Merge<Self> + LatticeOrd + NaiveLatticeOrd + IsBot +
#[sealed]
impl<T> Lattice for T where T: Sized + Merge<Self> + LatticeOrd + NaiveLatticeOrd + IsBot + IsTop {}

/// Alias trait for semirings.
#[sealed]
pub trait Semiring<T>: Addition<T> + Multiplication<T> + Zero<T> + One<T> {}
chaeyeonlee07 marked this conversation as resolved.
Show resolved Hide resolved

/// Trait for Semiring Addition.
pub trait Addition<Other> {
/// Add-assign `other` into self.
fn add(&mut self, other: Self);

/// Add `this` and `delta` together, returning the new value.
fn add_owned(mut self, other: Self) -> Self
where
Self: Sized,
{
self.add(other);
self
}
}

/// Trait for Semiring Multiplication.
pub trait Multiplication<Other> {
/// Multiply-assign `other` into self.
fn mul(&mut self, other: Self);

/// Multiply `this` and `delta` together, returning the new value.
fn mul_owned(mut self, other: Self) -> Self
where
Self: Sized,
{
self.mul(other);
self
}
}

/// Trait to check if semiring contains a zero.
pub trait Zero<T> {
/// Returns the zero element of the semiring. Identify for the Addition operation.
fn zero(&self) -> Self;
}

/// Trait to define a one in a semiring.
pub trait One<T> {
/// Returns the one element of the semiring. Identity for the multiplication operation.
fn one(&self) -> Self;
}
/// Trait for lattice merge (AKA "join" or "least upper bound").
pub trait Merge<Other> {
/// Merge `other` into the `self` lattice.
Expand Down
Loading