How do I create a variable where one index depends on the value of another index?

2018-08-07 Thread giannis . dafnomilis
Hello guys. I'm having an issue with a Python PulP MILP problem. You can find the simplified code that reproduces the problem here: from pulp import * machines = 2 I = range(machines) positions = 2 J = range(positions) years = 10 T = range(years) age = {0: 5, 1: 7} IR = 0.06 df = 0.3 costs = {

Re: How do I create a variable where one index depends on the value of another index?

2018-08-07 Thread giannis . dafnomilis
Hey Peter. This worked like a charm! I can't believe I did not think of that, after wasting so many hours on it. Thank you so much for the help! -- https://mail.python.org/mailman/listinfo/python-list

How to multiply dictionary values with other values based on the dictionary's key?

2018-08-18 Thread giannis . dafnomilis
I have the results of an optimization run in the form found in the following pic: https://i.stack.imgur.com/pIA7i.jpg. How can I multiply the dictionary values of the keys FEq_(i,_j,_k,_l) with preexisting values of the form A[i,j,k,l]? For example I want the value of key 'FEq_(0,_0,_2,_2)' mul

Re: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-19 Thread giannis . dafnomilis
Thank you MRAB! Now I can get the corresponding dictionary value A[i,j,k,l] for each key in the varsdict dictionary. However how would I go about multiplying the value of each FEq_(i,_j,_k,_l) key with the A[i,j,k,l] one? Do you have any insight in that? -- https://mail.python.org/mailman/list

Re: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-19 Thread giannis . dafnomilis
On Sunday, August 19, 2018 at 3:53:39 AM UTC+2, Steven D'Aprano wrote: > > Unless you edit your code with Photoshop, why do you think a JPEG is a > good idea? > > That discriminates against the blind and visually impaired, who can use > screen-readers with text but can't easily read text insid

Re: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-19 Thread giannis . dafnomilis
> Do you want to modify the varsdict values in place? > > varsdict['Feq_(i,_j,_k,_l)'] *= A[i,j,k,l] > > which is a short-cut for this slightly longer version: > > temp = varsdict['Feq_(i,_j,_k,_l)'] * A[i,j,k,l] > varsdict['Feq_(i,_j,_k,_l)'] = temp > > > > If you want to leave the origina

Re: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-19 Thread giannis . dafnomilis
On Sunday, August 19, 2018 at 1:42:29 PM UTC+2, Steven D'Aprano wrote: > On Sun, 19 Aug 2018 03:15:32 -0700, giannis.dafnomilis wrote: > > > Thank you MRAB! > > > > Now I can get the corresponding dictionary value A[i,j,k,l] for each key > > in the varsdict dictionary. > > > > However how would