亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? psmo_solver.cpp

?? 支持向量分類算法在linux操作系統下的是實現
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
{  int j;  NEXT_RAND = 1;  for (int i=0; i<n; ++i)  {    do      {	j = next_rand_pos() % l;      } while (work_status[j] != WORK_N);    work_status[j] = WORK_B;  }  int k=0; j=0;  for(int i=0; i<l; ++i)    {      if(work_status[i] == WORK_B)	{	  work_set[j] = i; ++j;	  work_count[i] = 0;	}      else	{	  not_work_set[k] = i; ++k;	  work_count[i] = -1;	}    }}void Solver_Parallel_SMO::Solve(int l, const QMatrix& Q, const double *b_, 				const schar *y_, double *alpha_, double Cp, 				double Cn, double eps, SolutionInfo* si, 				int shrinking){  double total_time = MPI_Wtime();  double problem_setup_time = 0;  double inner_solver_time = 0;  double gradient_updating_time = 0;  double time = 0;  // Initialization  this->l = l;  this->active_size = l;  this->Q = &Q;  this->si = si;  QD = Q.get_QD();  this->si = si;  clone(b,b_,l);  clone(y,y_,l);  clone(alpha,alpha_,l);  this->Cp = Cp;  this->Cn = Cn;  this->eps = eps;  this->lmn = l - n;  this->G_n = new double[lmn];  int *work_set = new int[n];  int *not_work_set = new int[l];  old_idx = new int[n];  memset(old_idx, -1, sizeof(int)*n);  double *delta_alpha = new double[n];  // Setup alpha, work and parallel cache status  {    alpha_status = new char[l];    work_status = new char[l];    work_count = new int[l];    p_cache_status = new char[size*l];    idx_cached = new int[n];    idx_not_cached = new int[n];    nz = new int[n];    for(int i=0; i<l; ++i)      {	update_alpha_status(i);	work_status[i] = WORK_N;	work_count[i] = -1;	for(int k=0; k<size; ++k)	  p_cache_status[k*size+i] = NOT_CACHED;      }  }  // Setup local index ranges  {    this->l_low = new int[size];    this->l_up = new int[size];    this->n_low = new int[size];    this->n_up = new int[size];    this->lmn_low = new int[size];    this->lmn_up = new int[size];    setup_range(l_low, l_up, l);    setup_range(n_low, n_up, n);    setup_range(lmn_low, lmn_up, lmn);    this->l_low_loc = l_low[rank];    this->l_up_loc = l_up[rank];    this->n_low_loc = n_low[rank];    this->n_up_loc = n_up[rank];    this->lmn_up_loc = lmn_up[rank];    this->lmn_low_loc = lmn_low[rank];//     this->local_l = l_up_loc - l_low_loc;//     this->local_n = n_up_loc - n_low_loc;//     this->local_lmn = lmn_up_loc - lmn_low_loc;  }  // Setup gradient  {    info("Initializing gradient..."); info_flush();    G = new double[l];    double *G_send = new double[l];    double *G_recv = new double[l];    for(int i=0; i<l; ++i)      {	G[i] = b[i];	G_send[i] = 0;      }    // Determine even distribution of work w.r.t.    // variables at lower bound    int k=0; int count_not_lower=0;    int *idx_not_lower = new int[l];    for(int i=0; i<l; ++i)      {	if(!is_lower_bound(i))	  {	    if(rank == k)	      {		// We have to compute it		idx_not_lower[count_not_lower]=i;		++count_not_lower;	      }	    k = k == size-1 ? 0 : k+1;	  }      }    // Compute local portion of gradient    for(int i=0; i<count_not_lower; ++i)      {	const Qfloat *Q_i = Q.get_Q(idx_not_lower[i],l);	double alpha_i = alpha[idx_not_lower[i]];	for(int j=0; j<l; ++j)	  G_send[j] += alpha_i * Q_i[j];      }    delete[] idx_not_lower;    // Get contributions from other processors    for(int k=0; k<size; ++k)      {	if(rank == k)	  {	    ierr = MPI_Bcast(G_send, l, MPIfloat, k, comm);	    CheckError(ierr);	    for(int i=0; i<l; ++i)	      G[i] += G_send[i];	  }	else	  {	    ierr = MPI_Bcast(G_recv, l, MPIfloat, k, comm);	    CheckError(ierr);	    for(int i=0; i<l; ++i)	      G[i] += G_recv[i];	  }      }    delete[] G_recv;    delete[] G_send;    info("done.\n"); info_flush();     ierr = MPI_Barrier(comm); CheckError(ierr);  }  // Allocate space for local subproblem  Q_bb = new Qfloat[n*n];  QD_b = new Qfloat[n];  alpha_b = new double[n];  c = new double[n];  a = new schar[n];//   time = clock(); //   double tmp = 0; //   for(int i=0; i<100; ++i) //     { //       for(int j=0; j<l; ++j) //         { //           tmp = Q.get_non_cached(i,j); //         } //     } //   time = clock() - time; //   printf("Computation time for 100 kernel rows = %.2lf\n", (double)time/CLOCKS_PER_SEC);   if(rank == 0)    {      info("  it  | setup time | solver it | solver time | gradient time ");      info("| kkt violation\n");    }  iter=0;  // Optimization loop  while(1)    {      // Only one processor does the working set selection.      int status = 0;      if(rank == 0)	{	  if(iter > 0)	    {	      time = MPI_Wtime();	      // info("Starting working set selection\n"); info_flush();	      status = select_working_set(work_set, not_work_set);	      // info("select ws time = %.2f\n", MPI_Wtime() - time);	    }	  else	    {	      // info("Starting init ws\n"); info_flush();	      init_working_set(work_set, not_work_set);	    }	}            // Send status to other processors.      ierr = MPI_Bcast(&status, 1, MPI_INT, 0, comm);      // Now check for optimality      if(status != 0)	break;      // Send new eps, as select_working_set might have      // changed it.      ierr = MPI_Bcast(&eps, 1, MPI_DOUBLE, 0, comm);      // Send new working set size and working set to other processors.      ierr = MPI_Bcast(&n, 1, MPI_INT, 0, comm);      ierr = MPI_Bcast(work_set, n, MPI_INT, 0, comm);      lmn = l - n;      ierr = MPI_Bcast(not_work_set, lmn, MPI_INT, 0, comm);      // Recompute ranges, as n and lmn might have changed      setup_range(n_low, n_up, n);      this->n_low_loc = n_low[rank];      this->n_up_loc = n_up[rank];      setup_range(lmn_low, lmn_up, lmn);      this->lmn_low_loc = lmn_low[rank];      this->lmn_up_loc = lmn_up[rank];//       this->local_n = n_up_loc - n_low_loc;//       this->local_lmn = lmn_up_loc - lmn_low_loc;      ++iter;      // Setup subproblem      time = MPI_Wtime();      for(int i=0; i<n; ++i)	{	  c[i] = G[work_set[i]];	  alpha_b[i] = alpha[work_set[i]];	  a[i] = y[work_set[i]];	}      //      info("Setting up Q_bb..."); info_flush();      for(int i=n_low_loc; i<n_up_loc; ++i)	{// 	  const Qfloat *Q_i = Q.get_Q_subset(work_set[i],work_set,n);	  if(Q.is_cached(work_set[i]))	    {	      const Qfloat *Q_i = Q.get_Q_subset(work_set[i],work_set,n);	      for(int j=0; j<=i; ++j)		{		  Q_bb[i*n+j] = Q_i[work_set[j]];		}	    }	  else if(old_idx[i] == -1)	    {	      for(int j=0; j<=i; ++j)		{		  // 	      Q_bb[i*n+j] = Q_i[work_set[j]];		  Q_bb[i*n+j] = Q.get_non_cached(work_set[i],work_set[j]);		}	    } 	  else	    {	      for(int j=0; j<i; ++j)		{		  if(old_idx[j] == -1)		    Q_bb[i*n+j] = Q.get_non_cached(work_set[i],work_set[j]);		  else		    Q_bb[i*n+j] = Q_bb[old_idx[j]*n+old_idx[i]];		}	      Q_bb[i*n+i] = Q.get_non_cached(work_set[i],work_set[i]);	    } 	}      // Synchronize Q_bb      ierr = MPI_Barrier(comm); CheckError(ierr);      int num_elements = 0;      for(int k=0; k<size; ++k)	{	  ierr = MPI_Bcast(&Q_bb[num_elements], (n_up[k]-n_low[k])*n, 			   MPI_FLOAT, k, comm);	  CheckError(ierr);	  num_elements += (n_up[k]-n_low[k])*n;	}      // Complete symmetric Q      for(int i=0; i<n; ++i)	{	  for(int j=0; j<i; ++j)	    Q_bb[j*n+i] = Q_bb[i*n+j];	}      for(int i=0; i<n; ++i)	{	  for(int j=0; j<n; ++j)	    {	      if(alpha[work_set[j]] > TOL_ZERO)		c[i] -= Q_bb[i*n+j]*alpha[work_set[j]];	    }	  QD_b[i] = Q_bb[i*n+i];	}      //info("done.\n"); info_flush();      time = MPI_Wtime() - time;      problem_setup_time += time;      if(rank == 0)	{	  info("%5d | %10.2f |",iter,time); info_flush();	  time = MPI_Wtime();	// Call SMO inner solver	  solve_inner();	  time = MPI_Wtime() - time;	  info(" %11.2f |", time); info_flush();	  inner_solver_time += time;	  	}      // Send alpha_b to other processors      ierr = MPI_Bcast(alpha_b, n, MPI_DOUBLE, 0, comm);      CheckError(ierr);      // Update gradient.      time = MPI_Wtime();      for(int i=0; i<n; ++i)	{	  delta_alpha[i] = alpha_b[i] - alpha[work_set[i]]; 	  if(fabs(delta_alpha[i]) > TOL_ZERO)	    nz[i] = 1;  	  else 	    nz[i] = 0;	}      //      info("Updating G_b..."); info_flush();      // Compute G_b      if(rank == 0)	{	  // Only first processor does updating, since	  // it has the whole Q_bb	  for(int i=0; i<n; ++i)	    for(int j=0; j<n; ++j) // G_b	      {		if(nz[j])		  G[work_set[i]] += Q_bb[n*i+j]*delta_alpha[j];	      }	}      //      info("done.\n"); info_flush();      determine_cached(work_set);    //   info("count_cached[%d] = %d, count_not_cached[%d] = %d\n", rank, //       	   count_cached, rank, count_not_cached); info_flush();//       MPI_Barrier(comm);      //      printf("count_cached = %d\n", count_cached);      // info("Updating G_n..."); info_flush();      // Compute G_n      for(int j=0; j<lmn; ++j)	G_n[j] = 0;      // First update the cached part...      for(int i=0; i<count_cached; ++i)	{	  const Qfloat *Q_i = Q.get_Q_subset(work_set[idx_cached[i]],					      not_work_set,lmn);	  for(int j=0; j<lmn; ++j)	    G_n[j] += Q_i[not_work_set[j]] * delta_alpha[idx_cached[i]];	}      // ...now update the non-cached part      for(int i=0; i<count_not_cached; ++i)	{	  const Qfloat *Q_i = Q.get_Q_subset(work_set[idx_not_cached[i]],					      not_work_set,lmn);	  for(int j=0; j<lmn; ++j)	    G_n[j] += Q_i[not_work_set[j]] * delta_alpha[idx_not_cached[i]];	}      //      info("done.\n"); info_flush();      // Synchronize gradient with other processors      //      info("Synchronizing gradient..."); info_flush();      sync_gradient(work_set, not_work_set);      //      info("done.\n"); info_flush();      time = MPI_Wtime() - time;      gradient_updating_time += time;      if(rank == 0)	info(" %13.2f |", time); info_flush();      // Update alpha      for(int i=0; i<n; ++i)	{	  alpha[work_set[i]] = alpha_b[i];	  update_alpha_status(work_set[i]);	}    } // while(1)  // Calculate rho  si->rho = calculate_rho();  // Calculate objective value  {    double v = 0;    int i;    for(i=0;i<l;i++)      v += alpha[i] * (G[i] + b[i]);    si->obj = v/2;  }  // Put back the solution  {    for(int i=0;i<l;i++)	alpha_[i] = alpha[i];  }  si->upper_bound_p = Cp;  si->upper_bound_n = Cn;  total_time = MPI_Wtime() - total_time;  // print timing statistics  if(rank == 0)    {      info("\n");      info("Total opt. time = %.2lf\n", total_time); info_flush();      info("Problem setup time = %.2lf (%.2lf%%)\n", problem_setup_time,	   problem_setup_time/total_time*100); info_flush();      info("Inner solver time = %.2lf (%.2lf%%)\n", inner_solver_time,	   inner_solver_time/total_time*100); info_flush();      info("Gradient updating time = %.2lf (%.2lf%%)\n", 	   gradient_updating_time, 	   gradient_updating_time/total_time*100); info_flush();    }  MPI_Barrier(comm);  info("\noptimization finished, #iter = %d\n",iter);  // Clean up  delete[] b;  delete[] y;  delete[] alpha;  delete[] alpha_status;  delete[] delta_alpha;  delete[] work_status;  delete[] work_count;  delete[] work_set;  delete[] not_work_set;  delete[] G;  delete[] Q_bb;  delete[] QD_b;  delete[] alpha_b;  delete[] c;  delete[] a;  delete[] l_low;  delete[] l_up;  delete[] n_low;  delete[] n_up;  delete[] lmn_low;  delete[] lmn_up;  delete[] G_n;  delete[] p_cache_status;  delete[] idx_cached;  delete[] idx_not_cached;  delete[] nz;}void Solver_Parallel_SMO::determine_cached(int *work_set){  count_cached = 0; count_not_cached = 0;  // Update local part of the parallel cache status  for(int i=0; i<l; ++i)    {      if(Q->is_cached(i))	p_cache_status[rank*l + i] = CACHED;      else	p_cache_status[rank*l + i] = NOT_CACHED;    }  // Synchronize parallel cache status  for(int k=0; k<size; ++k)    {      ierr = MPI_Bcast(&p_cache_status[k*l], l, MPI_CHAR, k, comm);       CheckError(ierr);	      }  // Smart parallel cache handling  int next_k = 0; bool found = false;  int next_not_cached = 0;  for(int i=0; i<n; ++i)    {      if(nz[i])	{	  for(int k=next_k; !found && k<size; ++k)	    {	      if(p_cache_status[k*l + work_set[i]] == CACHED)		{		  if(k == rank) // Do we have it?		    {		      idx_cached[count_cached] = i;		      ++count_cached;		    }		  found = true;		  next_k = k == size-1 ? 0 : k+1;		}	    }	  for(int k=0; !found && k<next_k; ++k)	    {	      if(p_cache_status[k*l + work_set[i]] == CACHED)		{		  if(k == rank) // Do we have it?		    {		      idx_cached[count_cached] = i;		      ++count_cached;		    }		  found = true;		  next_k = k == size-1 ? 0 : k+1;		} 	    }	  if(!found) // not in any cache	    {	      if(rank == next_not_cached) // Do we have to compute it?		{		  idx_not_cached[count_not_cached] = i;		  ++count_not_cached;		}	      next_not_cached = next_not_cached == size-1 ? 0 : 		next_not_cached + 1;	    }	  found = false;	} // if(nz[i])    }}void Solver_Parallel_SMO::setup_range(int *range_low, int *range_up, 				       int total_sz){  int local_sz = total_sz/size;  int idx_up = local_sz;  int idx_low = 0;  if(total_sz != 0)    {      for(int i=0; i<size-1; ++i)	{	  range_low[i] = idx_low;	  range_up[i] = idx_up;	  idx_low = idx_up;	  idx_up = idx_low + local_sz + 1;	}      range_low[size-1] = idx_low; range_up[size-1]=total_sz;    }  else    {      for(int i=0; i<size; ++i)	{	  range_low[i] = 0;	  range_up[i] = 0;	}    }}void Solver_Parallel_SMO::sync_gradient(int *work_set, int *not_work_set){  // Synchronize G_b  double *G_buf = new double[l];  if(rank == 0)    {      for(int i=0; i<n; ++i)	G_buf[i] = G[work_set[i]];    }  ierr = MPI_Bcast(G_buf, n, MPI_DOUBLE, 0, comm); CheckError(ierr);  if(rank != 0)    {      for(int i=0; i<n; ++i)	G[work_set[i]] = G_buf[i];    }  // Synchronize G_n  for(int i=0; i<size; ++i)    {      if(rank == i)	{	  for(int j=0; j<lmn; ++j)	    G_buf[j] = G_n[j];	}      ierr = MPI_Bcast(G_buf, lmn, MPI_DOUBLE, i, comm); CheckError(ierr);      // Accumulate contributions      for(int j=0; j<lmn; ++j)	G[not_work_set[j]] += G_buf[j];    }  delete[] G_buf;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
gogo大胆日本视频一区| 亚洲777理论| 亚洲伦在线观看| 人人狠狠综合久久亚洲| 91网站最新网址| 26uuuu精品一区二区| 亚洲国产精品自拍| 成人av在线影院| 精品成人一区二区| 日韩成人免费看| 色94色欧美sute亚洲线路二| 一区二区高清视频在线观看| 福利一区二区在线| 精品嫩草影院久久| 喷白浆一区二区| 精品一二三四区| 欧美综合视频在线观看| 综合久久久久久| 国产成人精品一区二| 久久久久国产精品人| 免费成人在线网站| 欧美绝品在线观看成人午夜影视| 亚洲视频中文字幕| www.成人网.com| 中文字幕中文字幕一区二区| 国产九色精品成人porny| 久久综合网色—综合色88| 人人超碰91尤物精品国产| 欧美日韩国产片| 亚洲国产精品尤物yw在线观看| 91福利国产精品| 亚洲一区二区欧美激情| 欧美色涩在线第一页| 亚洲最新视频在线播放| 91香蕉视频mp4| 夜夜夜精品看看| 欧美日本在线播放| 欧美一区二区高清| 一区二区三区欧美激情| 成人动漫视频在线| 亚洲国产精品传媒在线观看| 成人一道本在线| 国产精品网站在线播放| 91免费观看视频在线| 一区二区不卡在线播放 | 成人av午夜影院| 裸体一区二区三区| 日韩一区二区在线观看视频播放| 日韩精品91亚洲二区在线观看| 日韩精品综合一本久道在线视频| 亚洲色大成网站www久久九九| 国产成人精品免费看| 久久综合国产精品| 成人在线视频一区二区| 亚洲欧美日韩国产中文在线| 精品婷婷伊人一区三区三| 蜜臂av日日欢夜夜爽一区| 久久久青草青青国产亚洲免观| 懂色av一区二区在线播放| 亚洲精品乱码久久久久久 | 国产99久久久久| 一色桃子久久精品亚洲| 欧美群妇大交群中文字幕| 久久精品噜噜噜成人88aⅴ| 久久精品在线免费观看| 91麻豆精东视频| 六月丁香婷婷久久| 中文字幕免费一区| 51午夜精品国产| 制服丝袜一区二区三区| 粗大黑人巨茎大战欧美成人| www.在线欧美| 精品国产髙清在线看国产毛片| 国产酒店精品激情| 亚洲国产成人av网| 国产偷v国产偷v亚洲高清| 欧美日韩免费视频| 风流少妇一区二区| 日韩精品1区2区3区| 欧美极品美女视频| 日韩视频在线你懂得| 色哟哟在线观看一区二区三区| 久久精品国产亚洲5555| 亚洲美女免费视频| 亚洲国产精品激情在线观看| 91精选在线观看| 色综合天天综合| 国产精品亚洲专一区二区三区 | 成人午夜电影网站| 日本成人在线一区| 日韩成人伦理电影在线观看| 欧美成人精品福利| 不卡视频免费播放| 久久99国产精品免费网站| 亚洲已满18点击进入久久| 国产女人18毛片水真多成人如厕| 欧美久久久影院| 日本道色综合久久| 91影视在线播放| 成人性视频网站| 久久se这里有精品| 青娱乐精品视频| 日韩成人免费电影| 日韩和的一区二区| 五月婷婷另类国产| 亚洲小少妇裸体bbw| 一区二区三区欧美视频| 亚洲三级免费电影| 亚洲日本欧美天堂| 中文字幕日韩精品一区| 一区在线观看视频| 亚洲欧洲成人精品av97| 国产精品素人一区二区| 欧美日韩免费电影| av午夜精品一区二区三区| 丁香亚洲综合激情啪啪综合| 黄网站免费久久| 国产一区二区三区免费看| 极品美女销魂一区二区三区| 精品亚洲国产成人av制服丝袜| 免费看精品久久片| 精品一区二区免费在线观看| 玖玖九九国产精品| 国产成人午夜精品5599| av午夜一区麻豆| 在线看不卡av| 在线播放91灌醉迷j高跟美女| 欧美一级专区免费大片| 精品精品国产高清a毛片牛牛 | 26uuu成人网一区二区三区| 久久亚洲二区三区| 亚洲成av人在线观看| 五月天欧美精品| 精品亚洲免费视频| 成人免费高清在线观看| 日本高清成人免费播放| 色老头久久综合| 欧美性高清videossexo| 色婷婷久久久综合中文字幕| 日本道精品一区二区三区| 欧美日韩精品一区二区三区 | 不卡一区二区三区四区| 91网站最新网址| 在线综合视频播放| 久久久久久电影| 亚洲综合一区在线| 久久国产剧场电影| 91天堂素人约啪| 91精品国产91久久综合桃花 | 大胆欧美人体老妇| 欧美亚州韩日在线看免费版国语版| 7878成人国产在线观看| 国产三级一区二区| 日韩激情一区二区| jizz一区二区| 精品国产伦一区二区三区观看方式| 亚洲国产美女搞黄色| 玉足女爽爽91| 麻豆国产精品官网| 99久久99久久免费精品蜜臀| 欧美精品一卡两卡| 国产精品电影院| 久草精品在线观看| 在线观看日产精品| 国产欧美一区二区三区鸳鸯浴| 午夜精品爽啪视频| 99久久精品情趣| 精品区一区二区| 亚洲v日本v欧美v久久精品| 国产精品亚洲第一区在线暖暖韩国| 欧美在线观看禁18| 日本一区二区高清| 久久精品国产一区二区| 欧美三级在线视频| 国产精品视频观看| 国产乱国产乱300精品| 欧美精品xxxxbbbb| 亚洲一区二区五区| 91麻豆蜜桃一区二区三区| 久久精品无码一区二区三区| 三级久久三级久久| 欧美性猛交xxxxxx富婆| 亚洲三级在线播放| 91在线视频播放地址| 久久久噜噜噜久久人人看| 久久精品国产99国产精品| 在线观看成人小视频| 亚洲精品成人少妇| 91亚洲精品久久久蜜桃网站 | 亚洲成av人片一区二区三区| 91在线观看高清| 中文字幕欧美一区| 91在线无精精品入口| 国产精品国产馆在线真实露脸 | 欧美一区日韩一区| 亚洲成人免费在线观看| 欧美色综合久久| 亚洲成人精品在线观看| 欧美综合视频在线观看| 亚洲国产精品久久久男人的天堂 |