Very slow multiplication when the output is a variable with a big set of values as domain #3195
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What version of OR-Tools and what language are you using?
Version: 9.2.9972.
**Language:
Python
**Which solver are you using:
CP-SAT
**What operating system:
Linux 18.04
Hi,
I have a big problem with multiplication that I would be thankful if you could help me with.
I need to multiply a list of more than 2 variables e.g. [x1 , x2 , x3 , x4]. I understand that ortools only supports the multiplication of two varibales, thus I should calculcate the multiplication iteratively:
model.AddMultiplicationEquality(aux_var1 , [x1 , x2])
model.AddMultiplicationEquality(aux_var2 , [x3 , aux_var1])
etc.
Imagine, x1's domain is [1-1000] and x2 could only take values from the set {100 , 200}.
The most obvious way is to define aux_var1 to have a domain [100-200000]. This may not be the most efficient way as aux_var1 could only take very specific set of values in the range [100-200000]. I attempted to define aux_var1's domain as a set like {[100-100] , [200,200] , ... , [200000,200000]} but that makes the multiplication extremely slow.
Question 1: Is there any other efficient way I can calculate the multiplication of these 4 variables? (other than iterative approach)
Questin 2: In the aforementioned case, defining aux_var1's domain be [100-200000] is not efficient and my way of defining a set of numbers as domain is super slow. How else can I go about defining aux_var1's domain?
I look forward to receiving your help.
Regards,
Aria.
Beta Was this translation helpful? Give feedback.
All reactions