43 lines
1015 B
C++
43 lines
1015 B
C++
// Copyright 2022 James Pace
|
|
// All Rights Reserved.
|
|
//
|
|
// For a license to this software contact
|
|
// James Pace at jpace121@gmail.com.
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
#ifndef J7S__SIMPLEXSOLVER_HPP_
|
|
#define J7S__SIMPLEXSOLVER_HPP_
|
|
|
|
#include "j7s-optimization/CostFunction.hpp"
|
|
#include "j7s-optimization/common.hpp"
|
|
|
|
#include <vector>
|
|
|
|
namespace j7s
|
|
{
|
|
|
|
class SimplexSolver
|
|
{
|
|
public:
|
|
SimplexSolver(const CostFunction & costFunction, const std::vector<double> initSimplex);
|
|
|
|
IterationState update();
|
|
|
|
Coordinate bestCoord() const;
|
|
|
|
private:
|
|
const CostFunction m_costFunction;
|
|
std::vector<Coordinate> m_currentSimplex;
|
|
|
|
// Helper functions.
|
|
double newPoint() const;
|
|
std::vector<Coordinate> contract() const;
|
|
double calcVolume() const;
|
|
};
|
|
|
|
} // namespace j7s
|
|
|
|
#endif // J7S__SIMPLEXSOLVER_HPP_
|