Skip to content

Commit

Permalink
chore: convert into a workspace (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp authored Feb 22, 2024
1 parent cd4436e commit e84f599
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 741 deletions.
25 changes: 17 additions & 8 deletions Cargo.lock

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

604 changes: 0 additions & 604 deletions Cargo.nix

This file was deleted.

12 changes: 3 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[package]
name = "fluido-saturate"
version = "0.0.0"
edition = "2021"

[dependencies]
anyhow = "1.0.79"
clap = { version = "4.5.0", features = ["derive"] }
egg = "0.9.5"
[workspace]
resolver = "2"
members = ["mixer-generator", "fluido"]
113 changes: 38 additions & 75 deletions flake.lock

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

28 changes: 14 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
inputs = {
cargo2nix.url = "github:cargo2nix/cargo2nix/release-0.11.0";
flake-utils.follows = "cargo2nix/flake-utils";
nixpkgs.follows = "cargo2nix/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs = inputs: with inputs;
outputs = { self, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
pkgs = (import nixpkgs) {
inherit system;
overlays = [cargo2nix.overlays.default];
};

rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.75.0";
packageFun = import ./Cargo.nix;
};
naersk' = pkgs.callPackage naersk {};

in rec {
packages = {
fluido-saturate = (rustPkgs.workspace.fluido-saturate {});
default = packages.fluido-saturate;
release = true;
# For `nix build` & `nix run`:
defaultPackage = naersk'.buildPackage {
src = ./.;
};

# For `nix develop` (optional, can be skipped):
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo ];
};
}
);
Expand Down
9 changes: 9 additions & 0 deletions fluido/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "fluido"
version = "0.0.0"
edition = "2021"

[dependencies]
mixer-generator = { path = "../mixer-generator/" }
anyhow = "1.0.79"
clap = { version = "4.5.0", features = ["derive"] }
File renamed without changes.
31 changes: 31 additions & 0 deletions fluido/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
mod cmd;

use clap::Parser;
use cmd::Args;
use mixer_generator::concentration::Concentration;

fn main() -> anyhow::Result<()> {
let args = Args::try_parse()?;

let time_limit = args.time_limit;
let target_concentration = args.target_concentration;
let input_space = args
.input_space
.iter()
.map(|input_concentration| Concentration::from_f64(*input_concentration))
.collect();
println!(
"Starting to equality saturation, this will take ~{} seconds to finish.",
time_limit
);

let generated_mixer_sequence =
mixer_generator::saturate(target_concentration, time_limit, input_space)?;

let cost = generated_mixer_sequence.cost;
let expr = generated_mixer_sequence.best_expr;

println!("best expr: {expr}");
println!("cost: {cost}");
Ok(())
}
9 changes: 9 additions & 0 deletions mixer-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "mixer-generator"
version = "0.0.0"
edition = "2021"

[dependencies]
anyhow = "1.0.79"
clap = { version = "4.5.0", features = ["derive"] }
egg = "0.9.5"
19 changes: 19 additions & 0 deletions mixer-generator/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use clap::Parser;

/// Searching a mixer configuration from given input space and target concantration.
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Args {
/// Target concentration
#[arg(short, long)]
pub target_concentration: f64,

/// Input space, intial concentrations at hand.
/// example_input: [`0.2 0.3 0.4`]
#[arg(short, long)]
pub input_space: Vec<f64>,

/// Time limit in seconds.
#[arg(short, long)]
pub time_limit: u64,
}
File renamed without changes.
Loading

0 comments on commit e84f599

Please sign in to comment.