Percentage 补充

本文详细探讨了在智能财务管理中引入预测策略的方法,通过对比历史数据与即时信息,提出了一种混合预测模型,并应用于实际场景进行财务管理和预测。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  
  //add 8/26 begin
  
  double historyMax=42;
  double historyMin=10;
  
  ////tacitly mix min
  
  double tacitlyMax=test_3.get(0).value+(historyMax-test_3.get(0).value)/2;
  double tacitlyMix=historyMin;
  
  double forecastMax=0;
  double forecastMix=0;
  
  
 
  //add 8/26 over
  

 

//tacitly
  MoneyMenagement.moneyMenagementRecount_N4(3,test_3,tacitlyMax,tacitlyMix,30,100000,0.03,out);
  //forecast
  //MoneyMenagement.moneyMenagementRecount_N4(3,test_3,forecastMax,forecastMix,30,100000,0.03,out);
  
  

``` #include <cstdio> #include "gtest/gtest.h" #include <mutex> #include <omp.h> #include <atomic> std::mutex mu; thread_local int thread_refineProgress = 0; // progress bar for each thread std::atomic<int> all_percentage = 0; // total percent typedef void(*REFINE_CALLBACK)(int percentage); REFINE_CALLBACK refine_callback = nullptr; // refine call back float s_percent_ratio = 0.0f; // percent ratio for multi threads void callback(int percentage) { std::unique_lock<std::mutex> lock(mu); printf("percentage=%d\n", percentage); } int sum = 0; int N = 20; std::atomic<int> cur = 0; thread_local int thread_progress = 0; void callback2(int id, int percentage) { cur += percentage - thread_progress; thread_progress = percentage; { std::unique_lock<std::mutex> lock(mu); printf("id=%d, percentage=%d, allPercent=%d\n", id, percentage, cur / N); } } //void MyRefineCallBack(int percentage) { // if (percentage < thread_refineProgress) return; // all_percentage += percentage - thread_refineProgress; // thread_refineProgress = percentage; // // static std::atomic<int> bar; // bar = (all_percentage * s_percent_ratio); // if (bar > 100) { // bar = 100; // } // { // #pragma omp critical // { // printf("thread:%d, refine percentage: %d, all_percentage=%d\n", omp_get_thread_num(), percentage, (int)bar); // } // // if (refine_callback) { // refine_callback(bar); // } // } //}; #define PTRACE_DEBUG(str, value){ printf(str ##"\n",(value)); } void MyRefineCallBack(int percentage) { if (percentage < thread_refineProgress) return; all_percentage += percentage - thread_refineProgress; thread_refineProgress = percentage; static std::atomic<int> bar; bar = (all_percentage * s_percent_ratio); if (bar > 100) { bar = 100; } #pragma omp critical { PTRACE_DEBUG("refine percentage: %d", (int)bar); } if (refine_callback) { refine_callback(bar); } }; std::atomic<int> bar = 0; std::atomic<int> invalid_bar = 0; void call_back(int n) { if (bar > n) { printf("Error. n=%d, bar=%d\n", n, (int)bar); invalid_bar = 1; } bar = n; } int main0() { int n = 4; s_percent_ratio = 1.0f / n; bar = 0; refine_callback = call_back; #pragma omp parallel for for (int i = 0; i < n; i++) { thread_refineProgress = 0; int count = 1; for (int j = 0; j <= 100; j += 5) { if (count == 0 && j == 40) { j = -10; count = 1; printf("thread:%d, roll back test\n", omp_get_thread_num()); continue; } MyRefineCallBack(j); using namespace std::chrono_literals; //std::this_thread::sleep_for(0.1s); } } printf("all_percentage=%d\n", (int)all_percentage); //MyRefineCallBack(0); } TEST(ProgressBar, Case1) { for (int t = 0; t < 10; t++) { printf("\n*****case id=%d****\n", t); int n = 4; all_percentage = 0; s_percent_ratio = 1.0f / n; bar = 0; refine_callback = call_back; #pragma omp parallel for for (int i = 0; i < n; i++) { thread_refineProgress = 0; int count = 0; for (int j = 0; j <= 100; j += 5) { if (count == 0 && j == 40) { j = -10; count = 1; printf("thread:%d, roll back test\n", omp_get_thread_num()); continue; } MyRefineCallBack(j); using namespace std::chrono_literals; //std::this_thread::sleep_for(0.1s); } } printf("all_percentage=%d\n", (int)all_percentage); ASSERT_TRUE(invalid_bar == 0); } } //int main() { // sum = N * 100; // #pragma omp parallel for // for (int th = 0; th < N; th++) { // thread_progress = 0; // for (int i = 0; i <= 100; i += 10) { // callback2(th, i); // } // } //}```Error C4716 'main0': must return a value
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值