puan-rust

Crates.iopuan-rust
lib.rspuan-rust
version0.1.9
sourcesrc
created_at2022-09-23 11:52:33.749295
updated_at2024-01-10 09:24:03.204105
descriptionPuan package contain tools for defining logic relationships among linear inequalities and reduction algorithms.
homepage
repository
max_upload_size
id672431
size214,332
ourmoa (ourmoa)

documentation

README

Puan

Defining logic relationships among linear inequalities and has effective reduction algorithms.

Example

Here defining a relation between id 0, 1 and 2 saying that value of id 0 is dependent on value on id 1 and 2.

use puanrs::Theory;
use puanrs::Statement;
use puanrs::AtLeast;
use puanrs::Variable;
use puanrs::GeLineq;

let theory: Theory = Theory {
    id          : String::from("A"),
    statements  : vec![
        Statement {
            variable    : Variable {
                id      : 0,
                bounds  : (0,1),
            },
            expression  : Some(
                AtLeast {
                    ids     : vec![1,2],
                    bias   : -1,
                }
            )
        },
        Statement {
            variable    : Variable {
                id      : 1,
                bounds  : (0,1),
            },
            expression  : None
        },
        Statement {
            variable    : Variable {
                id      : 2,
                bounds  : (0,1),
            },
            expression  : None
        },
    ]
};

let actual: Vec<GeLineq> = theory.to_lineqs();
assert_eq!(actual.len(), 1);
assert_eq!(actual[0].bias, 0);
assert_eq!(actual[0].coeffs, vec![-1,1,1]);
assert_eq!(actual[0].indices, vec![0,1,2]);

If A=0, x=1, y=2 (with 0, 1, 2 here being variable id's), we could express above as A=x+y>=1.

Commit count: 0

cargo fmt