I am not really sure about how to define a decision variable by using integer_var_list(). Supposing I have a set of scalar decision variables X = [[x1,x2,x3,x4,x5,x6]], then I defined them as:
'''
x = np.empty((Total_T,1), dtype= object)
for i in range(Total_T):
x[i] = mdl.integer_var(lb= 0, ub= inf, name='x' + str(i+1))
Then I will get X as follows (each x is scalar).
[[x1]
[x2]
[x3]
[x4]
[x5]
[x6]]
'''
However when I tried following code:
'''
x = np.empty((Total_T,1), dtype= object)
for i in range(Total_T):
x = mdl.integer_var_list(Total_T,lb= 0, ub= inf, name='x' + str(i+1))
I got an error notice below.
[docplex.mp.Var(type=I,name='x6_0'), docplex.mp.Var(type=I,name='x6_1'),
docplex.mp.Var(type=I,name='x6_2'), docplex.mp.Var(type=I,name='x6_3'),
docplex.mp.Var(type=I,name='x6_4'), docplex.mp.Var(type=I,name='x6_5')]
Traceback (most recent call last):
File "C:/Users/pknu/Documents/Research/project/MILP Case 1 19 July 2022.py", line 78, in
<module>
x_in = get_index_value(1) #number 1 for transition in
File "C:/Users/pknu/Documents/Research/project/MILP Case 1 19 July 2022.py", line 73, in
get_index_value
get_value = x[ind_x]
TypeError: list indices must be integers or slices, not tuple
'''
Can anyone let me know:
- What are the keys in mdl.integer_var_list(keys, lb = None, ub=None, name =<class'str'>, key_format=None) and how to use it?
- Can I define X as mdl.integer_var_list but contains x[i] as mdl.integer_var for i from 0 to Total_T=6?
Thank you.
Best regards,
Nicholas