Univariate optimalisatie

Introductie tot optimalisatie in Python

Jasmin Ludolf

Content Developer

Voorbeeld: Optimalisatie in productie

 

Doelfunctie:

$P = 40q - 0.5q^2$

  • Univariaat: heeft één variabele

Winst versus hoeveelheid.

Introductie tot optimalisatie in Python

Voorbeeld: Optimalisatie in productie

 

Doelfunctie:

$P = 40q - 0.5q^2$

  • Univariaat: één variabele

Winst versus hoeveelheid.

Introductie tot optimalisatie in Python

Afgeleiden berekenen

 

Doelfunctie:

$P = 40q - 0.5q^2$

Afgeleide: beschrijft hoe de helling zich gedraagt

$\frac{dP}{dq} = 40 - q$

from sympy import symbols, diff, solve


q = symbols('q')
P = 40 * q - 0.5 * q**2
dp_dq = diff(P)
print(f"The derivative is: {dp_dq}")
The derivative is: 40 - 1.0*q
1 https://docs.sympy.org/latest/index.html
Introductie tot optimalisatie in Python

Het kritieke punt

Optimum waar de afgeleide nul is

  • Kritieke punten: punten waar de afgeleide nul is

Optimaal $q$ voldoet aan:

$\frac{dP}{dq} = 40 - q = 0$

q_opt = solve(dp_dq)
print(f"Optimum quantity: {q_opt}")
Optimum quantity: [40.0000000000000]
Introductie tot optimalisatie in Python

Maximum, minimum of geen van beide?

 

Winst versus hoeveelheid.

 

Doelfunctie:

$p = 40q - 0.5q^2$

q_opt = solve(p_prime)
print(f"Optimum quantity: {q_opt}")
Optimum quantity: [40.0000000000000]
Introductie tot optimalisatie in Python

Convexiteit en concaviteit

 

Concave functie.

  • Maximum

 

Convexe functie.

  • Minimum
Introductie tot optimalisatie in Python

Tweede afgeleide

 

  • De afgeleide van de afgeleide
  • Snelheid waarmee de helling verandert

 

  • Als 2e afgeleide op punt $< 0$: maximum
  • Als 2e afgeleide op punt $> 0$: minimum
  • Als 2e afgeleide op punt $= 0$: geen van beide

Winst versus hoeveelheid.

Introductie tot optimalisatie in Python

Voorbeeld: Maximum, minimum of geen van beide?

 

Afgeleide:

$\frac{dp}{dq} = 40 - q$

 

Tweede afgeleide:

$\frac{d^2p}{dq^2} = -1 < 0$

  • Maximum!

 

d2p_dq2 = diff(dp_dq)

sol = d2p_dq2.subs('q', q_opt)
print(f"The 2nd derivative is: {sol}")
The 2nd derivative is: -1.0000000000000
Introductie tot optimalisatie in Python

Afgeleiden in optimalisatie

 

  • Eerste afgeleiden
    • Vind kritieke punten bij optimalisatie
  • Tweede afgeleiden
    • Classificeer als minimum of maximum
Introductie tot optimalisatie in Python

Laten we oefenen!

Introductie tot optimalisatie in Python

Preparing Video For Download...