I have a decision variable array and I want to multiply each decision variable with a different integer of a list Here is an example:
#Import libraries
from rsome import ro
m=3
a = [0.10,0.1,1]
b = [0.13,0.1,0.3]
#create a model object
model = ro.Model('model')
x = model.dvar(m) #array of decision variables
y = model.dvar(m) #array of decision variables
#objective function
model.min(((a*x)- (b*y)).sum())
My question is how do I make sure this operation is actually doing an element wise multiplication ? When I check type of x or y type I get I get 3 continuous variables and PriceImp*Pimp is 1x3 affine expressions but is it element wise multiplication?
Please upgrade RSOME to the latest version, and make sure that coefficients like
aandbare defined asnp.ndarraytype objects, instead of lists.The
*operator performs element-wise multiplication, soa*xandb*yshould be "3 affine expressions". RSOME also supports broadcasting, just like NumPy, so if a 1x3 coefficient array times an array of 3 variables, the shape of the affine expression is 1x3.