Skip to content

Cost analysis

Jakob Beckmann edited this page May 12, 2019 · 23 revisions

Flop Count

Objective Functions

  • Sum = dim * 1
  • Sum of Squares = dim * 2
  • Sphere = dim * 2
  • Griewank = dim * 6
  • Rastigrin = dim * 7
  • Rosenbrock = (dim-1) * 8

GWO

Total Flops = 4n + population_size * objective_func_flopCount + max_iter(31n + population_size*objective_func_flopCount)

Pengu

Squirrel

Total Flops =

PSO

  • n = population_size*dim

Flop count for each function

  • pso_rand_init = 5n
  • pso_eval_fitness = population_size*objective_func_flopCount
  • pso_gen_init_velocity = 5 + 2n
  • pso_generate_vel_limit = 2 flops
  • pso_update_velocity = 11n flops
  • pso_update_position = n flops

Flop Count in Initialization

  • 7 + 7n + population_size*objective_func_flopCount flops

Flop Count Iteration

  • max_iter*(12n + swarm_size*obj_func_flops) flops

Total Flop Count

  • 7 + 7n + swarm_size*obj_func_flops + max_iter*(12n + swarm_size*obj_func_flops) flops

Memory Usage

PSO

Initialisation

All in number of floats:

  • min_vel = 1
  • max_vel = 1
  • current_positions = dim * swarm size
  • local_best_position = dim * swarm size
  • current_fitness = swarm size
  • local_best_fitness = swarm size
  • p_velocity = dim * swarm size
  • global_best_fitness = 1 (copy)
  • pso_best_fitness() uses 1 temporary float
  • pso_gen_init_velocity() temporarily assigns swarm size * dim array

Iteration

For every iteration:

  • pso_best_fitness() uses 1 temporary float, called once per iteration

Teardown

Solution memory allocation:

  • best_solution = dim

Total Memory Usage

This does not count the temporary allocation in the initialization of pso_gen_init_velocity().

In floats:

4 + 3(dim * swarm) + (2 * swarm) + iter + dim

In bytes:

16 + 12(dim * swarm) + (8 * swarm) + [4 * (iter + dim)]

Example

For dimension size 100, swarm size 10^6, iteration count 1000:

16 + 12*10^8 + 8*10^6 + 4*1100 = 1,208,004,416 = 2^(30.17)

This is slightly more than 1GB of memory (2^(30) bytes). Note that memory consumption is mostly determined by the 12(dim * swarm) term.