AGX Dynamics  2.37.2.0
BoxedKellerAlgorithm.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_BOXEDKELLERALGORITHM_H
18 #define AGX_BOXEDKELLERALGORITHM_H
19 
20 #include <agx/MixedLCP.h>
21 #include <agx/Logger.h>
22 
23 
24 namespace agx
25 {
27  {
28  public:
32  BoxedKellerAlgorithm( agx::Real globalTolerance, agx::UInt maxNumIterations, bool gatherStatistics );
33 
38 
43 
50  agx::Bool makeSolutionFeasible( Args& args, agx::UInt maxNumIterations = agx::UInt( 64 ) );
51 
52  protected:
53 
57  struct PivotIndex
58  {
59  PivotIndex() : index( agx::InvalidIndex ), sign( agx::Real( 0 ) ), done( false ) {}
60 
65  };
66 
71  struct StepLength
72  {
81  };
82 
83 #if 0
84 // List of solver statistics we want to extract. Some of these are not specific
85 // to Keller and should therefore be included in McpAlgorithmStats.
86  struct Stats
87  {
88  std::vector<int> inner_iterations;
89  size_t rank_update;
90  std::vector<int> updates;
91  int projections;
92  int projection_deletions;
93  int variables;
94  int active;
95  Stats( size_t n ) : inner_iterations(), updates(n, -1), rank_update(0), projections(0),
96  projection_deletions(0), variables(n), active(0){}
97 
98  Stats() : Stats(0){}
99  };
100 #endif
101 
102  protected:
103 
104 
105 
109  virtual ~BoxedKellerAlgorithm();
110 
114  virtual agx::UInt switchIndices( const agx::RealValarray& z, const agx::RealValarray& w, const agx::SparseRangeReal& bounds, agx::IndexSet& indexSet, agx::Real tolerance = agx::Real( 1E-8 ) ) const override;
115 
116 
117  protected:
122  void initializeIndexSet( Args& args ) const;
123 
128  void getInitialPoint( Args& args );
129 
135  PivotIndex getPivotIndex( Args& args ) const;
136 
143  agx::RealValarray getSearchDirection( Args& args, const agx::RealValarray& pivotCol );
144 
153  StepLength getStepLength( Args& args, const agx::RealValarray& searchDirection, const PivotIndex& pi, const agx::RealValarray& pivotRow ) const;
154 
163  void doStep( Args& args, const StepLength& sl, agx::RealValarray& searchDirection, const PivotIndex& pi, const agx::RealValarray& pivotCol ) const;
164 
172  agx::Bool doPivot( Args& args, const StepLength& sl, const PivotIndex& pi ) const;
173 
174 
175  protected:
177  };
178 
180 }
181 
182 #endif
bool Bool
Definition: Integer.h:48
#define AGXPHYSICS_EXPORT
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
Data for step length with the different thetas and indices (r2 and r3) of other bounded equations tha...
agx::ref_ptr< BoxedKellerAlgorithm > BoxedKellerAlgorithmRef
Essentially a sparse array of bounds.
Definition: SparseTypes.h:73
uint32_t UInt
Definition: Integer.h:34
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Data for pivot index with sign and current range of the most violated index.
Structure for all the arguments passed around.
Definition: MixedLCP.h:158
double Real
Definition: Real.h:42
Interface class for algorithm to solve general mixed complementarity problem.
Definition: MixedLCP.h:114
T sign(T v)
Definition: Math.h:328