File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.10.1 (2023-03-17)
2
+
3
+ - Add way to get upper and lower bounds of ` SatIntVar `
4
+
1
5
## 0.10.0 (2023-03-15)
2
6
3
7
- Updated OR-Tools to 9.6
Original file line number Diff line number Diff line change 3
3
4
4
#include " ext.h"
5
5
6
+ using operations_research::Domain;
6
7
using operations_research::sat::BoolVar;
7
8
using operations_research::sat::Constraint;
8
9
using operations_research::sat::CpModelBuilder;
@@ -98,8 +99,13 @@ namespace Rice::detail
98
99
}
99
100
100
101
void init_constraint (Rice::Module& m) {
102
+ Rice::define_class_under<Domain>(m, " Domain" )
103
+ .define_method (" min" , &Domain::Min)
104
+ .define_method (" max" , &Domain::Max);
105
+
101
106
rb_cSatIntVar = Rice::define_class_under<IntVar>(m, " SatIntVar" )
102
- .define_method (" name" , &IntVar::Name);
107
+ .define_method (" name" , &IntVar::Name)
108
+ .define_method (" domain" , &IntVar::Domain);
103
109
104
110
Rice::define_class_under<IntervalVar>(m, " SatIntervalVar" )
105
111
.define_method (" name" , &IntervalVar::Name);
Original file line number Diff line number Diff line change @@ -234,6 +234,17 @@ def test_add_hint
234
234
end
235
235
end
236
236
237
+ def test_int_var_domain
238
+ model = ORTools ::CpModel . new
239
+
240
+ lower_bound = ( 0 ..9 ) . to_a . sample
241
+ upper_bound = ( 10 ..19 ) . to_a . sample
242
+ x = model . new_int_var ( lower_bound , upper_bound , "x" )
243
+
244
+ assert_equal lower_bound , x . domain . min
245
+ assert_equal upper_bound , x . domain . max
246
+ end
247
+
237
248
def test_sum_empty_true
238
249
model = ORTools ::CpModel . new
239
250
model . add ( [ ] . sum < 2 )
You can’t perform that action at this time.
0 commit comments