lundi 4 avril 2016

function with array of random numbers as input

Can you please help me in figuring out how to write the input of a function as an output of array of random numbers and then plot the output of the function. The demand is unknown both today and in the future. I am trying to run a simulation which gives me the profit based on my decisions and hence I am trying to optimize that decision absed on the output.

TIA

import random
import matplotlib.pyplot as plt
import numpy as np
# S1 is the selling price in the first time period
# Q is the quantity obtained in the first time period
# C1 is the cost in the first time period
# C2 is the cost in the second time period
# S2 is the selling price in the second time period

S1 = 15
S2 = 50
Q = 10000
C1 = 10
Q1 = 100
D1 = np.random.uniform(10,50,1000)    
D2 = np.random.uniform(100,200,1000) 
C2 = 100
Q2 = Q-Q1
beta = 0.9

def min(x,y):
   if x < y:
       return x
   else:
       return y 
def plus(x,y):
    if x > y:
       return x
    else:
       return 0

def pro(S,C,Q,D):
    profit = S * min(D,Q) - C * plus(Q,D)
    return profit


pro1 = pro(S1,C1,Q1,D1)
pro2 = pro(S2,C2,Q2,D2)
Pro_Tot = pro2 + beta * pro1


# Plot of Pro_Tot as Z axis and D1 and D2 as X and Y axis:




Aucun commentaire:

Enregistrer un commentaire