18#include "absl/strings/str_format.h"
23#pragma warning(disable : 4351 4355 4804 4805)
28class IntervalVarStartExpr :
public BaseIntExpr {
30 explicit IntervalVarStartExpr(IntervalVar*
const i)
31 : BaseIntExpr(
i->solver()), interval_(
i) {}
34 IntervalVarStartExpr(
const IntervalVarStartExpr&) =
delete;
35 IntervalVarStartExpr& operator=(
const IntervalVarStartExpr&) =
delete;
36 ~IntervalVarStartExpr()
override {}
38 int64_t Min()
const override {
return interval_->StartMin(); }
40 void SetMin(int64_t m)
override { interval_->SetStartMin(m); }
42 int64_t Max()
const override {
return interval_->StartMax(); }
44 void SetMax(int64_t m)
override { interval_->SetStartMax(m); }
46 void SetRange(int64_t l, int64_t u)
override {
47 interval_->SetStartRange(l, u);
50 void SetValue(int64_t v)
override { interval_->SetStartRange(v, v); }
52 bool Bound()
const override {
53 return interval_->StartMin() == interval_->StartMax();
56 void WhenRange(Demon* d)
override { interval_->WhenStartRange(d); }
58 std::string DebugString()
const override {
59 return absl::StrFormat(
"start(%s)", interval_->DebugString());
62 void Accept(ModelVisitor*
const visitor)
const override {
69 IntervalVar* interval_;
72class IntervalVarEndExpr :
public BaseIntExpr {
74 explicit IntervalVarEndExpr(IntervalVar*
const i)
75 : BaseIntExpr(
i->solver()), interval_(
i) {}
78 IntervalVarEndExpr(
const IntervalVarEndExpr&) =
delete;
79 IntervalVarEndExpr& operator=(
const IntervalVarEndExpr&) =
delete;
80 ~IntervalVarEndExpr()
override {}
82 int64_t Min()
const override {
return interval_->EndMin(); }
84 void SetMin(int64_t m)
override { interval_->SetEndMin(m); }
86 int64_t Max()
const override {
return interval_->EndMax(); }
88 void SetMax(int64_t m)
override { interval_->SetEndMax(m); }
90 void SetRange(int64_t l, int64_t u)
override { interval_->SetEndRange(l, u); }
92 void SetValue(int64_t v)
override { interval_->SetEndRange(v, v); }
94 bool Bound()
const override {
95 return interval_->EndMin() == interval_->EndMax();
98 void WhenRange(Demon* d)
override { interval_->WhenEndRange(d); }
100 std::string DebugString()
const override {
101 return absl::StrFormat(
"end(%s)", interval_->DebugString());
104 void Accept(ModelVisitor*
const visitor)
const override {
111 IntervalVar* interval_;
114class IntervalVarDurationExpr :
public BaseIntExpr {
116 explicit IntervalVarDurationExpr(IntervalVar*
const i)
117 : BaseIntExpr(
i->solver()), interval_(
i) {}
120 IntervalVarDurationExpr(
const IntervalVarDurationExpr&) =
delete;
121 IntervalVarDurationExpr& operator=(
const IntervalVarDurationExpr&) =
delete;
122 ~IntervalVarDurationExpr()
override {}
124 int64_t Min()
const override {
return interval_->DurationMin(); }
126 void SetMin(int64_t m)
override { interval_->SetDurationMin(m); }
128 int64_t Max()
const override {
return interval_->DurationMax(); }
130 void SetMax(int64_t m)
override { interval_->SetDurationMax(m); }
132 void SetRange(int64_t l, int64_t u)
override {
133 interval_->SetDurationRange(l, u);
136 void SetValue(int64_t v)
override { interval_->SetDurationRange(v, v); }
138 bool Bound()
const override {
139 return interval_->DurationMin() == interval_->DurationMax();
142 void WhenRange(Demon* d)
override { interval_->WhenDurationRange(d); }
144 std::string DebugString()
const override {
145 return absl::StrFormat(
"duration(%s)", interval_->DebugString());
148 void Accept(ModelVisitor*
const visitor)
const override {
155 IntervalVar* interval_;
193 var->PerformedExpr()->
Var(),
var->StartExpr(), unperformed_value);
198 var->PerformedExpr()->
Var(),
var->DurationExpr(), unperformed_value);
203 var->PerformedExpr()->
Var(),
var->EndExpr(), unperformed_value);
IntVar * Var() override
Creates a variable from the expression.
static const char kStartExpr[]
static const char kEndExpr[]
static const char kDurationExpr[]
static const char kIntervalArgument[]
virtual std::string name() const
Object naming.
void set_name(absl::string_view name)
bool HasName() const
Returns whether the object has been named or not.
For the time being, Solver is neither MT_SAFE nor MT_HOT.
IntExpr * RegisterIntExpr(IntExpr *expr)
Registers a new IntExpr and wraps it inside a TraceIntExpr if necessary.
IntExpr * MakeConditionalExpression(IntVar *condition, IntExpr *expr, int64_t unperformed_value)
Conditional Expr condition ? expr : unperformed_value.
In SWIG mode, we don't want anything besides these top-level includes.
IntExpr * BuildStartExpr(IntervalVar *var)
--— Expression builders ---—
IntExpr * BuildSafeStartExpr(IntervalVar *var, int64_t unperformed_value)
IntExpr * BuildSafeEndExpr(IntervalVar *var, int64_t unperformed_value)
IntExpr * BuildEndExpr(IntervalVar *var)
IntExpr * BuildDurationExpr(IntervalVar *var)
IntExpr * BuildSafeDurationExpr(IntervalVar *var, int64_t unperformed_value)