Skip to content

Commit

Permalink
Adding foreign aggregators and wmc_with_disjunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
Liby99 committed Oct 4, 2023
1 parent 2c50ca9 commit 79cece1
Show file tree
Hide file tree
Showing 231 changed files with 6,116 additions and 3,880 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/scallop-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Scallop Core
on:
push:
branches: [ master ]
paths:
- "**.rs"
pull_request:
branches: [ master ]
paths:
- "**.rs"

env:
CARGO_TERM_COLOR: always
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/scallopy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
name: Scallopy

on: [push]
on:
push:
branches: [ master ]
paths:
- "**.py"
- "**.rs"
pull_request:
branches: [ master ]
paths:
- "**.py"
- "**.rs"

env:
SCALLOPDIR: ${{ github.workspace }}
Expand Down
16 changes: 15 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# (Latest) v0.2.0, Jun 11, 2023
# v0.2.2, (WIP)

- Adding `wmc_with_disjunctions` option for provenances that deal with boolean formulas for more accurate probability estimation

# v0.2.1, Sep 12, 2023

- Democratizing foreign functions and foreign predicates so that they can be implemented in Python
- Adding foreign attributes which are higher-order functions
- Adding `scallop-ext` the extension library and multiple Scallop plugins, including `scallop-gpt`, `scallop-clip`, and so on.
- Fixed multiple bugs related foreign predicate computation
- Adding `count!` aggregator for non-probabilistic operation
- Fixed sum and product aggregator so that they can accept additional argument
- Multiple bugs fixed; performance improved

# v0.2.0, Jun 11, 2023

- Fixing CSV loading and its performance; adding new modes to specify `keys`
- Adding `Symbol` type to the language
Expand Down
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scallop-core"
version = "0.2.0"
version = "0.2.1"
authors = ["Ziyang Li <[email protected]>"]
edition = "2018"

Expand All @@ -27,6 +27,7 @@ dateparser = "0.1.6"
dyn-clone = "1.0.10"
lazy_static = "1.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
parse_relative_duration = { path = "../lib/parse_relative_duration" }
rand = { version = "0.8", features = ["std_rng", "small_rng", "alloc"] }
astnode-derive = { path = "../lib/astnode-derive" }
Expand Down
42 changes: 37 additions & 5 deletions core/src/common/aggregate_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use super::value_type::*;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum AggregateOp {
Count { discrete: bool },
Sum(ValueType),
Prod(ValueType),
Sum { has_arg: bool, ty: ValueType },
Prod { has_arg: bool, ty: ValueType },
Min,
Argmin,
Max,
Expand All @@ -20,9 +20,27 @@ pub enum AggregateOp {
impl std::fmt::Display for AggregateOp {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Count { discrete } => if *discrete { f.write_str("discrete_count") } else { f.write_str("count") },
Self::Sum(t) => f.write_fmt(format_args!("sum<{}>", t)),
Self::Prod(t) => f.write_fmt(format_args!("prod<{}>", t)),
Self::Count { discrete } => {
if *discrete {
f.write_str("discrete_count")
} else {
f.write_str("count")
}
}
Self::Sum { has_arg, ty } => {
if *has_arg {
f.write_fmt(format_args!("sum_wa<{}>", ty))
} else {
f.write_fmt(format_args!("sum<{}>", ty))
}
}
Self::Prod { has_arg, ty } => {
if *has_arg {
f.write_fmt(format_args!("prod_wa<{}>", ty))
} else {
f.write_fmt(format_args!("prod<{}>", ty))
}
}
Self::Min => f.write_str("min"),
Self::Max => f.write_str("max"),
Self::Argmin => f.write_str("argmin"),
Expand Down Expand Up @@ -66,4 +84,18 @@ impl AggregateOp {
pub fn categorical_k(k: usize) -> Self {
Self::CategoricalK(k)
}

pub fn is_min_max(&self) -> bool {
match self {
Self::Min | Self::Max | Self::Argmin | Self::Argmax => true,
_ => false,
}
}

pub fn is_sum_prod(&self) -> bool {
match self {
Self::Sum { .. } | Self::Prod { .. } => true,
_ => false,
}
}
}
Loading

0 comments on commit 79cece1

Please sign in to comment.