Algorithms For Dummies


Employing Linear Programming



Download 7,18 Mb.
Pdf ko'rish
bet587/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   583   584   585   586   587   588   589   590   ...   651
Bog'liq
Algorithms

  Employing Linear Programming 

     367


a = np.linspace(0, 30, 30)

c1 = ((res['res_1']['t'] * res['res_1']['n'])-

      res['res_1']['A']*a) / res['res_1']['B']

c2 = ((res['res_2']['t'] * res['res_2']['n'])-

      res['res_2']['A']*a) / res['res_2']['B']

c3 = ((res['res_3']['t'] * res['res_3']['n'])-

      res['res_3']['A']*a) / res['res_3']['B']

plt.plot(a, c1, label='constrain #1')

plt.plot(a, c2, label='constrain #2')

plt.plot(a, c3, label='constrain #3')

axes = plt.gca()

axes.set_xlim([0,30])

axes.set_ylim([0,30])

plt.xlabel('qty model A')

plt.ylabel('qty model B')

border = np.array((c1,c2,c3)).min(axis=0)

plt.fill_between(a, border, color='yellow', alpha=0.5)

plt.scatter(*zip(*[(0,0), (20,0),

                   (0,20), (16,6), (6,16)]))

plt.legend()

plt.show()

The constraints turn into three lines on a chart, as shown in Figure 19-2. The lines 

intersect among themselves, showing the feasible area. This is the area delimited 

by the three lines whose A and B values are always inferior or equal compared to 

the values on any of the constraint lines. (The constraints represent a frontier; you 

can’t have A or B values beyond them.)

According to the simplex method, the optimal solution is one of the five vertexes 

of the polygon (which are (0,0), (20,0), (0,20), (16,6), and (6,16)). You can dis-

cover which one is the solution by setting the necessary functions from the PuLP 

package. First, define the problem and call it model. By doing so, you determine 

that it’s a maximization problem and that both A and B should be positive.

model = pulp.LpProblem("Max profit", pulp.LpMaximize)

A = pulp.LpVariable('A', lowBound=0)

B = pulp.LpVariable('B', lowBound=0)




368


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   583   584   585   586   587   588   589   590   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish