-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParticle.h
45 lines (40 loc) · 1.06 KB
/
Particle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef PARTICLE_H
#define PARTICLE_H
#include <iostream>
#include <string>
#include "Function.h"
#include "Vector.h"
#include "SwarmGenerator.h"
class Particle
{
private:
Vector *position;
Vector *velocity;
Vector *pBest;
double w;
double c1;
double c2;
double vMax;
public:
//|[attr1,...,attrN]|[v1,...,vN]|w|c1|c2|
Particle(std::string line);
Particle(const Particle &other);
~Particle();
void updateParticle(const Particle &gBest);
const Vector& getPosition() const;
const Vector& getVelocity() const;
const Vector *getPBest() const;
void setVMax(double vMax);
double evaluate(const Function& function);
bool equal(const Particle& other) const;
const std::string toString() const
{
std::string result = "P: " + (position != NULL ? position->toString() : "NULL") + "\tV: " + (velocity != NULL ? velocity->toString() : "NULL");
return result;
}
double getW() const;
double getC1() const;
double getC2() const;
double getVMax() const;
};
#endif /*PARTICLE_H*/