1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker 35a3110598 Squashed 'software/chuffed/' content from commit 2ed0c015
git-subtree-dir: software/chuffed
git-subtree-split: 2ed0c01558d2a5c49c1ce57e048d32c17adf92d3
2021-06-18 09:36:35 +10:00

69 lines
1.7 KiB
C++

#ifndef int_var_el_h
#define int_var_el_h
#include <chuffed/core/options.h>
class IntVarEL : public IntVar {
int lit_min;
int lit_max;
int base_vlit;
int base_blit;
Lit getNELit(int v) const { return toLit(base_vlit+2*v); }
Lit getEQLit(int v) const { return toLit(base_vlit+2*v+1); }
Lit getGELit(int v) const { return toLit(base_blit+2*v); }
Lit getLELit(int v) const { return toLit(base_blit+2*v+1); }
void channelMin(int v);
void channelMax(int v);
void channelFix(int v);
#if INT_DOMAIN_LIST
void updateMin(int v, int i);
void updateMax(int v, int i);
#else
void updateMin();
void updateMax();
#endif
void updateFixed();
public:
int uiv_no;
IntVarEL(const IntVar& other);
void initVLits();
void initBLits();
void setVLearnable(bool b = true);
void setBLearnable(bool b = true);
void setVDecidable(bool t);
void setBDecidable(bool t);
VarType getType() { return INT_VAR_EL; }
int getBaseVLit() { return base_vlit; }
int getBaseBLit() { return base_blit; }
Lit getEQLit2(int v) const { return toLit(base_vlit+2*v+1); }
// t = 0: [x != v], t = 1: [x = v], t = 2: [x >= v], t = 3: [x <= v]
Lit getLit(int64_t v, int t);
Lit getMinLit() const { return ~getGELit(min); }
Lit getMaxLit() const { return ~getLELit(max); }
Lit getValLit() const { assert(isFixed()); return ~getEQLit(min); }
Lit getFMinLit(int64_t v) { return ~getLit(so.finesse ? v : (int) min, 2); }
Lit getFMaxLit(int64_t v) { return ~getLit(so.finesse ? v : (int) max, 3); }
bool setMin(int64_t v, Reason r = NULL, bool channel = true);
bool setMax(int64_t v, Reason r = NULL, bool channel = true);
bool setVal(int64_t v, Reason r = NULL, bool channel = true);
bool remVal(int64_t v, Reason r = NULL, bool channel = true);
Lit createSetLit(vec<Lit>& head);
};
#endif