Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:15

0001 // Created on: 2014-07-18
0002 // Created by: Alexander Malyshev
0003 // Copyright (c) 2014-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _math_PSOParticlesPool_HeaderFile
0017 #define _math_PSOParticlesPool_HeaderFile
0018 
0019 #include <NCollection_Array1.hxx>
0020 
0021 //! Describes particle pool for using in PSO algorithm.
0022 //! Indexes:
0023 //! 0 <= aDimidx <= myDimensionCount - 1
0024 struct PSO_Particle
0025 {
0026   Standard_Real* Position; // Data for pointers allocated within PSOParticlesPool instance.
0027   Standard_Real* Velocity; // Not need to delete it manually.
0028   Standard_Real* BestPosition;
0029   Standard_Real Distance;
0030   Standard_Real BestDistance;
0031 
0032   PSO_Particle()
0033   {
0034     Distance = RealLast();
0035     BestDistance = RealLast();
0036     Position = 0;
0037     Velocity = 0;
0038     BestPosition = 0;
0039   }
0040 
0041   //! Compares the particles according to their distances.
0042   bool operator< (const PSO_Particle& thePnt) const
0043   {
0044     return Distance < thePnt.Distance;
0045   }
0046 };
0047 
0048 // Indexes:
0049 // 1 <= aParticleIdx <= myParticlesCount
0050 class math_PSOParticlesPool
0051 {
0052 public:
0053 
0054   Standard_EXPORT math_PSOParticlesPool(const Standard_Integer theParticlesCount,
0055                                         const Standard_Integer theDimensionCount);
0056 
0057   Standard_EXPORT PSO_Particle* GetParticle(const Standard_Integer theIdx);
0058 
0059   Standard_EXPORT PSO_Particle* GetBestParticle();
0060 
0061   Standard_EXPORT PSO_Particle* GetWorstParticle();
0062 
0063   Standard_EXPORT ~math_PSOParticlesPool();
0064 
0065 private:
0066 
0067   NCollection_Array1<PSO_Particle> myParticlesPool;
0068   NCollection_Array1<Standard_Real> myMemory; // Stores particles vector data.
0069   Standard_Integer myParticlesCount;
0070   Standard_Integer myDimensionCount;
0071 };
0072 
0073 #endif