Skip to content

Commit

Permalink
Implement ordering variables in the CNF struct
Browse files Browse the repository at this point in the history
  • Loading branch information
gskorokhod committed Nov 28, 2023
1 parent ae37d66 commit cb858d2
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 259 deletions.
12 changes: 10 additions & 2 deletions conjure_oxide/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ impl Model {
pub fn add_variable(&mut self, name: Name, decision_var: DecisionVariable) {
self.variables.insert(name, decision_var);
}

pub fn add_constraint(&mut self, expression: Expression) {
// ToDo (gs248) - there is no checking whatsoever
// We need to properly validate the expression but this is just for testing
self.constraints.push(expression);
}
}

impl Default for Model {
Expand Down Expand Up @@ -90,11 +96,13 @@ pub enum Expression {

Sum(Vec<Expression>),

Not(Box<Expression>),
Or(Vec<Expression>),
And(Vec<Expression>),

Eq(Box<Expression>, Box<Expression>),
Neq(Box<Expression>, Box<Expression>),
Geq(Box<Expression>, Box<Expression>),
Not(Box<Expression>),
Or(Vec<Expression>),
Leq(Box<Expression>, Box<Expression>),
Gt(Box<Expression>, Box<Expression>),
Lt(Box<Expression>, Box<Expression>),
Expand Down
Loading

0 comments on commit cb858d2

Please sign in to comment.