jeudi 30 mars 2017

Cannot convert object of type 'list' to a numeric value

I am making a pyomo model, where i want to use random numbers for my two dimensional parameters. I put a small python script for random numbers that looks exactly what i wanted to see for my two dimensional parameter. I am getting a TypeError: Cannot convert object of type 'list'(value =[[....]] to a numeric value. in my objective function. Below is my objective function and random numbers script.

model.obj = Objective(expr=sum(model.C[v,l] * model.T[v,l] for v in model.V for l in model.L) + \
            sum(model.OC[o,l] * model.D[o,l] for o in model.O for l in model.L), sense=minimize)

import random
C = [[] for i in range(7)]
for i in range(7):
     for j in range(5):
        C[i]+= [random.randint(100,500)]
model.C = Param(model.V, model.L, initialize=C)

Please let me know if someone can help fixing this.




Aucun commentaire:

Enregistrer un commentaire