1 // Created on: 2014-07-18
2 // Created by: Alexander Malyshev
3 // Copyright (c) 2014-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _math_PSOParticlesPool_HeaderFile
17 #define _math_PSOParticlesPool_HeaderFile
19 #include <NCollection_Array1.hxx>
21 //! Describes particle pool for using in PSO algorithm.
23 //! 0 <= aDimidx <= myDimensionCount - 1
26 Standard_Real* Position; // Data for pointers allocated within PSOParticlesPool instance.
27 Standard_Real* Velocity; // Not need to delete it manually.
28 Standard_Real* BestPosition;
29 Standard_Real Distance;
30 Standard_Real BestDistance;
34 Distance = RealLast();
35 BestDistance = RealLast();
41 //! Compares the particles according to their distances.
42 bool operator< (const PSO_Particle& thePnt) const
44 return Distance < thePnt.Distance;
49 // 1 <= aParticleIdx <= myParticlesCount
50 class math_PSOParticlesPool
54 Standard_EXPORT math_PSOParticlesPool(const Standard_Integer theParticlesCount,
55 const Standard_Integer theDimensionCount);
57 Standard_EXPORT PSO_Particle* GetParticle(const Standard_Integer theIdx);
59 Standard_EXPORT PSO_Particle* GetBestParticle();
61 Standard_EXPORT PSO_Particle* GetWorstParticle();
63 Standard_EXPORT ~math_PSOParticlesPool();
67 NCollection_Array1<PSO_Particle> myParticlesPool;
68 NCollection_Array1<Standard_Real> myMemory; // Stores particles vector data.
69 Standard_Integer myParticlesCount;
70 Standard_Integer myDimensionCount;