I have a parameter B
in matrix format, defined in the model file as
param B {Rn,Rn};
for which I define the non-sparse values as
from numpy import random
from scipy import sparse
from amplpy import AMPL, Environment, dataframe
B = random.randint(0, 2, (3, 3))
BSparse = sparse.lil_matrix(B)
dfB = dataframe.DataFrame(('RnRow', 'RnCol'), 'val')
dfB.setValues({
(i+1, j+1): BSparse.data[i][jPos]
for i, row in enumerate(BSparse.rows)
for jPos, j in enumerate(row)
})
Later on, when I want to solve my model, the solver complains
Error executing "solve" command:
error processing constraint f[1]:
no value for B[1,1]
Apparently, missing values have not value 0
by default. How can I set that up to be the default value?