1 /* Copyright (c) 2015 Regents of the University of California
3 * Author: Brian Demsky <bdemsky@uci.edu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
10 #include "branchrecord.h"
12 #include "constraint.h"
15 BranchRecord::BranchRecord(EPRecord *r, uint nvars, Constraint **cvars, bool isalwaysexecuted) :
17 hasNext(r->getNextRecord()!=NULL),
19 numdirections(r->numValues()),
20 alwaysexecuted(isalwaysexecuted),
21 vars((Constraint **)model_malloc(sizeof(Constraint *)*nvars)) {
22 memcpy(vars, cvars, sizeof(Constraint *)*nvars);
25 BranchRecord::~BranchRecord() {
29 Constraint * BranchRecord::getAnyBranch() {
33 return new Constraint(OR, numvars, vars);
36 Constraint * BranchRecord::getNewBranch() {
37 return new Constraint(AND, numvars, vars);
40 Constraint * BranchRecord::getBranch(EPValue *val) {
41 int index=branch->getIndex(val);
45 return generateConstraint(numvars, vars, index);
48 int BranchRecord::getBranchValue(bool * array) {
50 for(int j=numvars-1;j>=0;j--) {
52 if (array[vars[j]->getVar()])