Exemple #1
0
    def first_objective(self, package_amount):
        simulator = Simulator()
        start = time.time()
        min_mean = 100000000000
        best_config = []
        simulation_amount = 0
        for i in range(1, 31):
            for j in range(1, 32):
                for w in range(1, 73):
                    for o in range(1, 14):
                        config = [i, j, w, o]
                        if simulator.get_config_cost(config) <= 1000:
                            simulation_amount += 1
                            sr = simulator.simulate(config, package_amount, i + j + w + o)
                            mean = (sr[0] + sr[1] + sr[2] + sr[3]) / (4.0 * package_amount)
                            if mean < min_mean:
                                min_mean = mean
                                best_config = config

        end = time.time()
        print("Duro: " + str(end - start))
        print("Media minima: " + str(min_mean))
        print("Mejor configuracion: " + str(best_config))
        print("Costo de la configuracion: " + str(simulator.get_config_cost(best_config)))
        print("Cantidad de simulaciones: " + str(simulation_amount))
Exemple #2
0
 def main(self):
     server_costs = [29.4, 28.3, 12.1, 69.6]
     phase = 4
     inc = 1
     s = Simulator()
     config = [107, 860, 235, 121]
     initial_mean = 69331.61131299718
     sr = s.simulate(config, 1000, 1)
     mean = (sr[0] + sr[1] + sr[2] + sr[3]) / (1000.0 * 4)
     diff = initial_mean - mean
     grade = diff / (server_costs[phase - 1] * inc)
     print(grade)
     print(mean)
print("now enter the angel of projectile:(rad)")
angel = float(input())
print("-----------------------------------------------")
print("it's time for air to play its role, enter radius of ball:(m)")
radius = float(input())
print("-----------------------------------------------")
print("ohh we forget about mass :), enter the mass of projectile:(kg)")
mass = float(input())
print("-----------------------------------------------")
print(
    "at the end enter time duration:(s)  *[the less time duration is the accurate your graphs will be]*"
)
delta_t = float(input())

simulator = Simulator(mass, initial_velocity, angel, radius, delta_t)
simulator.simulate()
Plotter.plot(simulator.y_components, simulator.x_components, r'$y\/(m)$',
             r'$x\/(m)$', "[y-x]graph")
Plotter.plot(simulator.x_components, simulator.time, r'$x\/(m)$', r'$t\/(s)$',
             "[x-t]graph")
Plotter.plot(simulator.y_components, simulator.time, r'$y\/(m)$', r'$t\/(s)$',
             "[y-t]graph")
Plotter.plot(simulator.v_x_components, simulator.time, r'$\.x\/(m/s)$',
             r'$t\/(s)$', "[xdot-t]graph")
Plotter.plot(simulator.v_y_components, simulator.time, r'$\.y\/(m/s)$',
             r'$t\/(s)$', "[ydot-t]graph")
Plotter.plot(simulator.v_x_components, simulator.x_components, r'$\.x\/(m/s)$',
             r'$x\/(m)$', "[xdot-x]graph")
Plotter.plot(simulator.v_y_components, simulator.y_components, r'$\.y\/(m/s)$',
             r'$y\/(m)$', "[ydot-y]graph")