84 lines
3.0 KiB
C++
84 lines
3.0 KiB
C++
|
/********************************************************
|
||
|
* ██████╗ ███████╗████████╗██╗
|
||
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||
|
* ██║ ███╗███████╗ ██║ ██║
|
||
|
* ██║ ██║╚════██║ ██║ ██║
|
||
|
* ╚██████╔╝███████║ ██║ ███████╗
|
||
|
* ╚═════╝ ╚══════╝ ╚═╝ ╚══════╝
|
||
|
* Generic Scientific Template Library
|
||
|
*
|
||
|
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
||
|
*
|
||
|
* The GSTL is distributed under a dual licensing scheme. You can redistribute
|
||
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation, either version 2
|
||
|
* of the License, or (at your option) any later version. You should have
|
||
|
* received a copy of the GNU Lesser General Public License (LGPL) along with
|
||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
||
|
* the GSTL, please consider the option to obtain a commercial license for a
|
||
|
* fee. These licenses are offered by the GSTL's original author. As a rule,
|
||
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
||
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
||
|
* to include some description of your company and the realm of its activities.
|
||
|
* Also add information on how to contact you by electronic and paper mail.
|
||
|
******************************************************/
|
||
|
|
||
|
#include "../../lib/optimization.h"
|
||
|
|
||
|
class levy_planner : public gctl::lgd_solver
|
||
|
{
|
||
|
public:
|
||
|
levy_planner(){}
|
||
|
virtual ~levy_planner(){}
|
||
|
virtual double LGD_Evaluate(const gctl::array<double> &x, gctl::array<double> &g){return 0;}
|
||
|
};
|
||
|
|
||
|
int main(int argc, char *argv[]) try
|
||
|
{
|
||
|
gctl::display_logo();
|
||
|
|
||
|
levy_planner p;
|
||
|
gctl::lgd_para my_para = p.default_lgd_para();
|
||
|
|
||
|
double alpha, beta;
|
||
|
std::cout << "Input alpha (> 0) and beta (1.0 ~ 2.0): ";
|
||
|
std::cin >> alpha >> beta;
|
||
|
|
||
|
if (alpha <= 0 || beta <= 1.0 || beta >= 2.0)
|
||
|
{
|
||
|
std::cout << "Invalid inputs\n";
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
my_para.flight_times = 100000;
|
||
|
my_para.beta = beta;
|
||
|
p.set_lgd_para(my_para);
|
||
|
|
||
|
gctl::array<double> dist;
|
||
|
p.get_levy_distribution(dist);
|
||
|
|
||
|
for (size_t i = 0; i < dist.size(); i++)
|
||
|
{
|
||
|
dist[i] *= alpha;
|
||
|
}
|
||
|
|
||
|
double mean = dist.mean();
|
||
|
double std = dist.std();
|
||
|
double cnt = 0.0;
|
||
|
|
||
|
for (size_t i = 0; i < dist.size(); i++)
|
||
|
{
|
||
|
if (fabs(dist[i] - mean) > 3.0*std) cnt += 1.0;
|
||
|
}
|
||
|
|
||
|
std::cout << "Step Avg. = " << mean << "\n";
|
||
|
std::cout << "Step STD = " << std << "\n";
|
||
|
std::cout << "Large Ones = " << cnt/1000.0 << "%\n";
|
||
|
return 0;
|
||
|
}
|
||
|
catch (std::exception &e)
|
||
|
{
|
||
|
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
||
|
}
|