| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
// simplex method |
| 14 |
#ifndef __SIMPLEX_H |
| 15 |
#define __SIMPLEX_H |
| 16 |
|
| 17 |
#include "nvector.h" |
| 18 |
#include "nfunction.h" |
| 19 |
|
| 20 |
#include <iostream> |
| 21 |
|
| 22 |
|
| 23 |
template<class T,int n> |
| 24 |
class simplex_method |
| 25 |
{ |
| 26 |
private: |
| 27 |
nfunction<T,n>* m_func; |
| 28 |
nvector<T,n> m_vert[n+1]; |
| 29 |
T m_val[n+1]; |
| 30 |
|
| 31 |
nvector<T,n> reflect(int); |
| 32 |
void insert(const nvector<T,n>&,T,int); |
| 33 |
void shrink(); |
| 34 |
void sort(); |
| 35 |
|
| 36 |
public: |
| 37 |
simplex_method(nfunction<T,n>*); |
| 38 |
|
| 39 |
nvector<T,n> solve(T,const nvector<T,n> &,int max=-1); |
| 40 |
}; |
| 41 |
|
| 42 |
#include "simplex.hh" |
| 43 |
|
| 44 |
#endif //__SIMPLEX_H |