-1

When I run the following code:

for key,value in before_yield_ts.items():
    print(key,value)

Before this block of code:

 # The result of the objective function is here
    final_amount_ts = value (prob_ts.objective)
    print ("Total", final_amount_ts)

This is the error that I get:

Traceback (most recent call last):
  File "metal_blend.py", line 181, in <module>
    final_amount_ts = value (prob_ts.objective)
TypeError: 'float' object is not callable

1 Answers1

1

After the code block

for key,value in before_yield_ts.items():
    print(key,value)

value is now a float number representing the last item in the dictionary. It is not changed afterwards.

In the line

final_amount_ts = value (prob_ts.objective) The parentheses after "value" are being applied as an operator on it, in other words, you are attempting to call value as if it were a function, when it is actually a float.

Mike Jack
  • 130
  • 9
  • If i use that directly then I get Total 800.0*input_mat_M_ts1 + 227.98*input_mat_M_ts10 + 329.97*input_mat_M_ts11 + 329.97*input_mat_M_ts12 + 329.97*input_mat_M_ts13 + 870.0*input_mat_M_ts14 + 870.0*input_mat_M_ts15 + 870.0*input_mat_M_ts16 + 4920.43*input_mat_M_ts17 + 5991.88*input_mat_M_ts18 + 1477.77*input_mat_M_ts19 + 950.0*input_mat_M_ts2 + 1477.77*input_mat_M_ts20 + 3272.87*input_mat_M_ts21 + 20.0*input_mat_M_ts22 + 800.0*input_mat_M_ts3 + 900.0*input_mat_M_ts4 + 1158.38*input_mat_M_ts5 + 1104.69*input_mat_M_ts6 + 66.37*input_mat_M_ts7 + 276.06*input_mat_M_ts8 + 227.98*input_mat_M_ts9 –  May 26 '21 at 15:09