mirror of
https://github.com/ellmau/adf-obdd.git
synced 2025-12-19 09:29:36 +01:00
Edition 2021, fmt applied
Signed-off-by: Stefan Ellmauthaler <stefan.ellmauthaler@tu-dresden.de>
This commit is contained in:
parent
e0855f9e22
commit
611501588a
@ -2,7 +2,7 @@
|
|||||||
name = "adf_bdd"
|
name = "adf_bdd"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
authors = ["Stefan Ellmauthaler <stefan.ellmauthaler@tu-dresden.de>"]
|
authors = ["Stefan Ellmauthaler <stefan.ellmauthaler@tu-dresden.de>"]
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
||||||
description = "Solver for ADFs grounded semantics by utilising OBDDs - ordered binary decision diagrams"
|
description = "Solver for ADFs grounded semantics by utilising OBDDs - ordered binary decision diagrams"
|
||||||
|
|||||||
127
flake.lock
generated
Normal file
127
flake.lock
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1627913399,
|
||||||
|
"narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1634851050,
|
||||||
|
"narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c91f3de5adaf1de973b797ef7485e441a65b8935",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1623875721,
|
||||||
|
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignoresrc": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1635165013,
|
||||||
|
"narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1636552551,
|
||||||
|
"narHash": "sha256-k7Hq/bvUnRlAfFjPGuw3FsSqqspQdRHsCHpgadw6UkQ=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "9e86f5f7a19db6da2445f07bafa6694b556f9c6d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-21.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1628186154,
|
||||||
|
"narHash": "sha256-r2d0wvywFnL9z4iptztdFMhaUIAaGzrSs7kSok0PgmE=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "06552b72346632b6943c8032e57e702ea12413bf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"gitignoresrc": "gitignoresrc",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils_2",
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1636683315,
|
||||||
|
"narHash": "sha256-udsMHw5gzZPvvFIhopoGicLK/LaYyDN3iAa1PEpP7uM=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "e87b7ea329fc78c5e5775c983193f630458c317f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
40
flake.nix
Normal file
40
flake.nix
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
description = "basic rust flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
flake-compat = {
|
||||||
|
url = "github:edolstra/flake-compat";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
gitignoresrc = {
|
||||||
|
url = "github:hercules-ci/gitignore.nix";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils, flake-compat, gitignoresrc, rust-overlay, ... }@inputs:
|
||||||
|
{
|
||||||
|
#overlay = import ./nix { inherit gitignoresrc; };
|
||||||
|
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import rust-overlay)];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
devShell =
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.rust-bin.stable.latest.default
|
||||||
|
pkgs.rust-analyzer
|
||||||
|
pkgs.cargo-audit
|
||||||
|
pkgs.cargo-license
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
42
flake.nix~
Normal file
42
flake.nix~
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
description = "d2sgraph - a program to show the graphs (based on d2sparql)";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
flake-compat = {
|
||||||
|
url = "github:edolstra/flake-compat";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
gitignoresrc = {
|
||||||
|
url = "github:hercules-ci/gitignore.nix";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils, flake-compat, gitignoresrc, rust-overlay, ... }@inputs:
|
||||||
|
{
|
||||||
|
#overlay = import ./nix { inherit gitignoresrc; };
|
||||||
|
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import rust-overlay)];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
devShell =
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.rust-bin.stable.latest.default
|
||||||
|
pkgs.rust-analyzer
|
||||||
|
pkgs.cargo-audit
|
||||||
|
pkgs.cargo-license
|
||||||
|
pkgs.graphviz
|
||||||
|
pkgs.clingo
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
13
shell.nix
Normal file
13
shell.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(import
|
||||||
|
(
|
||||||
|
let
|
||||||
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
|
in
|
||||||
|
fetchTarball {
|
||||||
|
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||||
|
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
{
|
||||||
|
src = ./.;
|
||||||
|
}).shellNix.default
|
||||||
@ -31,5 +31,5 @@
|
|||||||
//! ac(c,neg(b)).
|
//! ac(c,neg(b)).
|
||||||
//! ac(d,d).
|
//! ac(d,d).
|
||||||
//! ```
|
//! ```
|
||||||
pub mod obdd;
|
|
||||||
pub mod adf;
|
pub mod adf;
|
||||||
|
pub mod obdd;
|
||||||
|
|||||||
10
src/obdd.rs
10
src/obdd.rs
@ -59,11 +59,7 @@ impl Bdd {
|
|||||||
if lo == hi {
|
if lo == hi {
|
||||||
lo
|
lo
|
||||||
} else {
|
} else {
|
||||||
let node = BddNode {
|
let node = BddNode { var, lo, hi };
|
||||||
var,
|
|
||||||
lo,
|
|
||||||
hi,
|
|
||||||
};
|
|
||||||
match self.hash.get(&node) {
|
match self.hash.get(&node) {
|
||||||
Some(n) => *n,
|
Some(n) => *n,
|
||||||
None => {
|
None => {
|
||||||
@ -79,7 +75,6 @@ impl Bdd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn variable(&mut self, var: usize) -> Term {
|
pub fn variable(&mut self, var: usize) -> Term {
|
||||||
self.create_node(var, BDD_BOT, BDD_TOP)
|
self.create_node(var, BDD_BOT, BDD_TOP)
|
||||||
}
|
}
|
||||||
@ -94,7 +89,8 @@ impl Bdd {
|
|||||||
|
|
||||||
pub fn restrict(&mut self, subtree: Term, var: usize, val: bool) -> Term {
|
pub fn restrict(&mut self, subtree: Term, var: usize, val: bool) -> Term {
|
||||||
let treenode = self.nodes[subtree];
|
let treenode = self.nodes[subtree];
|
||||||
#[allow(clippy::collapsible_else_if)] // Better readabilty of the if/then/else structure of the algorithm
|
#[allow(clippy::collapsible_else_if)]
|
||||||
|
// Better readabilty of the if/then/else structure of the algorithm
|
||||||
if treenode.var > var || treenode.var == usize::MAX {
|
if treenode.var > var || treenode.var == usize::MAX {
|
||||||
subtree
|
subtree
|
||||||
} else if treenode.var < var {
|
} else if treenode.var < var {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user