Skip to content

Commit

Permalink
Resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
gskorokhod committed Jan 26, 2024
2 parents 4c5d575 + 4828e4d commit 71e26b9
Show file tree
Hide file tree
Showing 20 changed files with 383 additions and 124 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/code-coverage.yml
pull_request:
paths:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/code-coverage.yml
workflow_dispatch:

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/doc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/doc-coverage.yml
pull_request:
paths:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/doc-coverage.yml
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: dawidd6/action-download-artifact@v2
with:
name: docs-${{ steps.sha.outputs.result }}
workflow: docs.yml
workflow: docs-generate.yml
path: ./deploy

- name: Deploy to Github Pages
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ on:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/format.yml
pull_request:
paths:
- Cargo.*
- conjure-oxide/**
- solvers/**
- crates/**
- .github/actions/format.yml
workflow_dispatch:

Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ on:
- main # run for pushes to the main branch. other branches need to create a PR if they want testing.
paths:
- conjure_oxide/**
- solvers/**
- crates/**
- Cargo.*
- .github/workflows/test.yml
pull_request:
paths:
- conjure_oxide/**
- solvers/**
- crates/**
- Cargo.*
- .github/workflows/test.yml
workflow_dispatch:


jobs:

Job:

build-and-test:
name: "Build and Test"
strategy:
# run all combinations of the matrix even if one combination fails.
fail-fast: false
matrix:
rust_release:
- stable
Expand Down Expand Up @@ -57,7 +61,7 @@ jobs:

- run: rustup update ${{ matrix.rust_release }} && rustup default ${{ matrix.rust_release }}

- run: cargo build -vv
- run: cargo build -vv --workspace

- name: Add conjure to PATH
run: echo "${HOME}/.cargo/bin/conjure-v${{ matrix.conjure_version }}-${{ matrix.release_suffix }}-with-solvers" >> ${GITHUB_PATH}
Expand All @@ -76,6 +80,19 @@ jobs:
fi
conjure --version
- run: cargo test
- run: cargo test --workspace

audit:
name: "Dependency Audit"
runs-on: ubuntu-latest
strategy:
# run all combinations of the matrix even if one combination fails.
fail-fast: false
matrix:
rust_release:
- stable
- nightly
steps:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.rust_release }} && rustup default ${{ matrix.rust_release }}
- run: cargo audit
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/conjure-oxide.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"rust": {
{
"rust-analyzer.check.command": "check",
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
"editor.formatOnSave": true,
}
6 changes: 3 additions & 3 deletions conjure_oxide/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub mod error;
pub mod find_conjure;
pub mod parse;
pub mod rules;
mod solvers;
mod rules;
pub mod solvers;

pub use conjure_core::ast; // re-export core::ast as conjure_oxide::ast
pub use conjure_core::ast::Model; // rexport core::ast::Model as conjure_oxide::Model
pub use conjure_core::solvers::Solver;

pub use error::Error;
pub use error::Error;
80 changes: 77 additions & 3 deletions conjure_oxide/src/rules/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,81 @@
use conjure_core::{ast::Expression, rule::RuleApplicationError};
use conjure_core::{ast::Expression as Expr, rule::RuleApplicationError};
use conjure_rules::register_rule;

// #[register_rule]
// fn identity(expr: &Expr) -> Result<Expr, RuleApplicationError> {
// Ok(expr.clone())
// }

#[register_rule]
fn sum_constants(expr: &Expr) -> Result<Expr, RuleApplicationError> {
match expr {
Expr::Sum(exprs) => {
let mut sum = 0;
let mut new_exprs = Vec::new();
let mut changed = false;
for e in exprs {
match e {
Expr::ConstantInt(i) => {
sum += i;
changed = true;
}
_ => new_exprs.push(e.clone()),
}
}
if !changed {
return Err(RuleApplicationError::RuleNotApplicable);
}
new_exprs.push(Expr::ConstantInt(sum));
Ok(Expr::Sum(new_exprs)) // Let other rules handle only one Expr being contained in the sum
}
_ => Err(RuleApplicationError::RuleNotApplicable),
}
}

#[register_rule]
fn unwrap_sum(expr: &Expr) -> Result<Expr, RuleApplicationError> {
match expr {
Expr::Sum(exprs) if (exprs.len() == 1) => Ok(exprs[0].clone()),
_ => Err(RuleApplicationError::RuleNotApplicable),
}
}

#[register_rule]
fn flatten_sum_geq(expr: &Expr) -> Result<Expr, RuleApplicationError> {
match expr {
Expr::Geq(a, b) => {
let exprs = match a.as_ref() {
Expr::Sum(exprs) => Ok(exprs),
_ => Err(RuleApplicationError::RuleNotApplicable),
}?;
Ok(Expr::SumGeq(exprs.clone(), b.clone()))
}
_ => Err(RuleApplicationError::RuleNotApplicable),
}
}

#[register_rule]
fn sum_leq_to_sumleq(expr: &Expr) -> Result<Expr, RuleApplicationError> {
match expr {
Expr::Leq(a, b) => {
let exprs = match a.as_ref() {
Expr::Sum(exprs) => Ok(exprs),
_ => Err(RuleApplicationError::RuleNotApplicable),
}?;
Ok(Expr::SumLeq(exprs.clone(), b.clone()))
}
_ => Err(RuleApplicationError::RuleNotApplicable),
}
}

#[register_rule]
fn identity(expr: &Expression) -> Result<Expression, RuleApplicationError> {
Ok(expr.clone())
fn lt_to_ineq(expr: &Expr) -> Result<Expr, RuleApplicationError> {
match expr {
Expr::Lt(a, b) => Ok(Expr::Ineq(
a.clone(),
b.clone(),
Box::new(Expr::ConstantInt(-1)),
)),
_ => Err(RuleApplicationError::RuleNotApplicable),
}
}
5 changes: 3 additions & 2 deletions conjure_oxide/src/solvers/minion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use crate::ast::{
DecisionVariable, Domain as ConjureDomain, Expression as ConjureExpression,
Model as ConjureModel, Name as ConjureName, Range as ConjureRange,
};
pub use minion_rs::ast::Model as MinionModel;
use minion_rs::ast::{
Constant as MinionConstant, Constraint as MinionConstraint, Model as MinionModel,
Var as MinionVar, VarDomain as MinionDomain,
Constant as MinionConstant, Constraint as MinionConstraint, Var as MinionVar,
VarDomain as MinionDomain,
};

const SOLVER: Solver = Solver::Minion;
Expand Down
1 change: 0 additions & 1 deletion conjure_oxide/src/solvers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod error;

pub mod minion;
pub mod kissat;

Expand Down
Loading

0 comments on commit 71e26b9

Please sign in to comment.