Otimização e Simulação
Repositório de trabalhos:
GitHub - LLxD/Opt-Sim-Py
Contribute to LLxD/Opt-Sim-Py development by creating an account on GitHub.
Nota: Trabalhos e 2 projetos (em grupo)
O problema escolhe a linguagem, não vocês - Peretta
Calculo Numérico
Como o computador faz cálculos?
- Ponto Flutuante, IEEE 754
Mantissa → Coeficiente do 2 é negativo (primeiro bit é 2⁻¹ até 2⁻²³)
Expoente → Coeficiente do 2 é positivo (primeiro bit é 2⁸ até 2⁰)
Épsilon de Máquina
Derivada Numérica
import numpy as np
import matplotlib.pyplot as plt
def dfdt(f,t):
h = 2**-36
return(f(t+h) - f(t-h))/(2*h)
t = np.linspace(0,2*np*pi, 100)
fun = lambda t : np.sin(t)
plt.plot(t,fun(t), 'b', label='seno')
plt.plot(t,dfdt(fun,t)), 'b', label='cosseno')
plt.legend()
plt.show()
Trabalho 01 - First Exercise
first derivative
dfdt(f,t) = (f(t+h) - f(t-h))/(2*h)
second derivative
d²/dt² f(t) = d/dt(d/dt f(t))
d/dt sin = cos
Trabalho 02 - Second Exercise
- Least squares problem
- Linear solving of systems
- Polynomial Interpolation
Trabalho 03 - Third Exercise
- LP Problem of optimization
Results:
Number_of_employees_that_work_on_monday = 8.0
Number_of_employees_that_work_on_tuesday = 0.0
Number_of_employees_that_work_on_wednesday = 3.0
Number_of_employees_that_work_on_thursday = 5.0
Number_of_employees_that_work_on_friday = 2.0
Number_of_employees_that_work_on_saturday = 3.0
Number_of_employees_that_work_on_sunday = 2.0
Total Number of Employees = 23.0
Diferenças Finitas
- Wikipedia: Finite difference
Aleatoriedade
- Imprevisibilidade
- Retorno à média (Central Limit Theorem) - Wikipedia
- É possível identificar uma distribuição de probabilidade
- Distribuição normal (Gaussiana) - Wikipedia
- LCG (Linear Congruential Generator) - Wikipedia
- Mersenne Twister - Wikipedia
- Random.org
- Box-Muller - Wikipedia
- Big Crunch - Wikipedia
Box-muller Exercise
Monte Carlo
Gambler's Ruin
Se o jogador tem menos de 50% de chance de ganhar, ele não deve apostar.
Markov Chain
Uma forma de usar estados não-determinísticos para conseguir probabilidades de mudanças com base em dados históricos.
É uma simulação estocástica, então, é necessário simular várias vezes e fazer uma média do valor de interesse.