• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ graphchi_context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中graphchi_context的典型用法代码示例。如果您正苦于以下问题:C++ graphchi_context类的具体用法?C++ graphchi_context怎么用?C++ graphchi_context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了graphchi_context类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: after_iteration

 /**
  * Called after an iteration has finished.
  */
 void after_iteration(int iteration, graphchi_context &gcontext) {
   /*
    * If there were changes in the current iteration, then iterate once more.
    * If there were no changes, stop execution by setting current iteration to last iteration. 
    */
     if(gcontext.scheduler->num_tasks() > 0)
         gcontext.set_last_iteration(iteration+1);
     else
         gcontext.set_last_iteration(iteration);
    
 }
开发者ID:poojanilangekar,项目名称:graph_simulation,代码行数:14,代码来源:graphchi_simulation.cpp


示例2: before_exec_interval

    /**
     * Called before an execution interval is started.
     *
     * On every even iteration, we load pivot's item connected user lists to memory.
     * Here we manage the memory to ensure that we do not load too much
     * edges into memory.
     */
    void before_exec_interval(vid_t window_st, vid_t window_en, graphchi_context &gcontext) {

        /* on even iterations, loads pivot items into memory base on the membudget_mb allowed memory size */
        if ((gcontext.iteration % 2 == 0)) {
            //if (debug){
            printf("entering iteration: %d on before_exec_interval\n", gcontext.iteration);
            printf("pivot_st is %d window_St %d, window_en %d\n", adjcontainer->pivot_st, window_st, window_en);
            //}
            if (adjcontainer->pivot_st < std::min(std::min((int)M,end_user), (int)window_en)) {
                size_t max_grab_edges = get_option_long("membudget_mb", 1024) * 1024 * 1024 / 8;
                if (grabbed_edges < max_grab_edges * 0.8) {
                    Rcpp::Rcerr << "Window init, grabbed: " << grabbed_edges << " edges" << " extending pivor_range to : " << window_en + 1 << std::endl;
                    adjcontainer->extend_pivotrange(std::min(std::min((int)M, end_user), (int)window_en + 1));
                    Rcpp::Rcerr << "Window en is: " << window_en << " vertices: " << gcontext.nvertices << std::endl;
                    if (window_en+1 >= gcontext.nvertices) {
                        // every user was a pivot item, so we are done
                        Rcpp::Rcerr<<"Setting last iteration to: " << gcontext.iteration + 2 << std::endl;
                        gcontext.set_last_iteration(gcontext.iteration + 2);
                    }
                } else {
                    Rcpp::Rcerr << "Too many edges, already grabbed: " << grabbed_edges << std::endl;
                }
            }
        }

    }
开发者ID:thirdwing,项目名称:RcppGraphChi,代码行数:33,代码来源:itemsim2rating.cpp


示例3: after_iteration

 /**
  * Called after an iteration has finished.
  */
 void after_iteration(int iteration, graphchi_context &ginfo) {
   logstream(LOG_DEBUG)<<mytimer.current_time() << "iteration: " << iteration << " changes: " << changes << std::endl;
   if (changes == 0)
     ginfo.set_last_iteration(iteration);
   changes = 0;
   iter++;
 }
开发者ID:JustgoFlyme,项目名称:graphchi,代码行数:10,代码来源:bond_percolation.cpp


示例4: before_exec_interval

  /**
   * Called before an execution interval is started.
   *
   * On every even iteration, we load pivot's item connected user lists to memory. 
   * Here we manage the memory to ensure that we do not load too much
   * edges into memory.
   */
  void before_exec_interval(vid_t window_st, vid_t window_en, graphchi_context &gcontext) {        

    /* on even iterations, loads pivot items into memory base on the membudget_mb allowed memory size */
    if (gcontext.iteration % 2 == 0) {
      if (!quiet){
        printf("entering iteration: %d on before_exec_interval\n", gcontext.iteration);
        printf("pivot_st is %d window_en %d\n", adjcontainer->pivot_st, window_en);
      }
      if (adjcontainer->pivot_st <= window_en) {
        size_t max_grab_edges = get_option_long("membudget_mb", 1024) * 1024 * 1024 / 8;
        if (grabbed_edges < max_grab_edges * 0.8) {
          logstream(LOG_DEBUG) << "Window init, grabbed: " << grabbed_edges << " edges" << " extending pivor_range to : " << window_en + 1 << std::endl;
          adjcontainer->extend_pivotrange(window_en + 1);
          logstream(LOG_DEBUG) << "Window en is: " << window_en << " vertices: " << gcontext.nvertices << std::endl;
          if (window_en+1 == gcontext.nvertices) {
            // every item was a pivot item, so we are done
            logstream(LOG_DEBUG)<<"Setting last iteration to: " << gcontext.iteration + 2 << std::endl;
            gcontext.set_last_iteration(gcontext.iteration + 2);                    
          }
        } else {
          logstream(LOG_DEBUG) << "Too many edges, already grabbed: " << grabbed_edges << std::endl;
        }
      }
    }

  }
开发者ID:prashantc29,项目名称:graphchi-cpp,代码行数:33,代码来源:itemcf.cpp


示例5: after_iteration

    void after_iteration(int iteration, graphchi_context &gcontext) {
        //first_iteration = false;
		if(converged){
			logstream(LOG_INFO)<<"scc_forward has finished!"<<std::endl;
			gcontext.set_last_iteration(iteration);
		}
    }
开发者ID:warnon,项目名称:mzj_graphchi_ori,代码行数:7,代码来源:DAGdistract.cpp


示例6: update

    /**
      * Pagerank update function.
      */
    void update(graphchi_vertex<VertexDataType, EdgeDataType> &v, graphchi_context &ginfo) {
        float sum=0;
        if (ginfo.iteration == 0) {
            /* On first iteration, initialize vertex and out-edges. 
               The initialization is important,
               because on every run, GraphChi will modify the data in the edges on disk. 
             */
	    update_edge_data(v, 1.0);
            v.set_data(RANDOMRESETPROB); 
        } else {
            /* Compute the sum of neighbors' weighted pageranks by
               reading from the in-edges. */
            for(int i=0; i < v.num_inedges(); i++) {
                //float val = v.inedge(i)->get_data();
                //sum += val;                    
		struct weightE eData = v.inedge(i)->get_data();
		sum += eData.pagerank;
            }
            
            /* Compute my pagerank */
            float pagerank = RANDOMRESETPROB + (1 - RANDOMRESETPROB) * sum;
            
            /* Write my pagerank divided by the number of out-edges to
               each of my out-edges. */
	    update_edge_data(v, pagerank);
                
            /* Keep track of the progression of the computation.
               GraphChi engine writes a file filename.deltalog. */
            ginfo.log_change(std::abs(pagerank - v.get_data()));
            
            /* Set my new pagerank as the vertex value */
            v.set_data(pagerank); 
        }
    }
开发者ID:carriercomm,项目名称:TrueTop,代码行数:37,代码来源:pagerank-struct.cpp


示例7: after_iteration

    /**
      * Called after an iteration has finished. Not implemented.
      */
    void after_iteration(int iteration, graphchi_context &ginfo) {
		if(iteration == 0){

		}else if(iteration == 1){
			fflush(fp_list);
			ginfo.set_last_iteration(iteration);	
		}
    }
开发者ID:warnon,项目名称:mzj_graphchi_ori,代码行数:11,代码来源:WeightedDAGmsBFS.cpp


示例8: after_iteration

	/**
	 * Called after an iteration has finished.
	 */
	void after_iteration(int iteration, graphchi_context &ginfo) {
		/*	
			if (converged) {
			std::cout << "Converged!" << std::endl;
			ginfo.set_last_iteration(iteration);
			}
			*/
		if(iteration == 1)	
			ginfo.set_last_iteration(iteration);
	}
开发者ID:warnon,项目名称:block-graphchi,代码行数:13,代码来源:partition_hash.cpp


示例9: run_validation4

void run_validation4(graphchi_engine<VertexDataType, EdgeDataType> * pvalidation_engine, graphchi_context & context){
   //no validation data, no need to run validation engine calculations
   cur_iteration = context.iteration;
   if (pvalidation_engine == NULL){
     std::cout << std::endl;
     return;
   }
   ValidationRMSEProgram4 program;
   pvalidation_engine->run(program, 1);
   if (converged_engine)
     context.set_last_iteration(cur_iteration);
}
开发者ID:CVML,项目名称:graphchi-cpp,代码行数:12,代码来源:rmse_engine4.hpp


示例10: after_iteration

 /**
  * Called after an iteration has finished.
  */
 void after_iteration(int iteration, graphchi_context &gcontext) {
     training_objective = sum(objective_vec);
     Rcpp::Rcout<<"  Training objective:" << std::setw(10) << training_objective << std::endl;
     if (halt_on_mrr_decrease > 0 && halt_on_mrr_decrease < cur_iteration && training_objective < last_training_objective) {
         Rcpp::Rcout << "Stopping engine because of validation objective decrease" << std::endl;
         gcontext.set_last_iteration(gcontext.iteration);
     }
     Rcpp::Rcerr << "after_iteration: running validation engine" << std::endl;
     run_validation(pvalidation_engine, gcontext);
     if (verbose)
         Rcpp::Rcout<<"Average step size: " << sum(stat_vec)/(double)M << "Node without edges: " << node_without_edges << std::endl;
     sgd_gamma *= sgd_step_dec;
 }
开发者ID:thirdwing,项目名称:RcppGraphChi,代码行数:16,代码来源:climf.cpp


示例11: after_iteration

 /**
  * Called after an iteration has finished.
  */
 void after_iteration(int iteration, graphchi_context &gcontext)
 {
   training_objective = sum(objective_vec);
   std::cout<<"  Training objective:" << std::setw(10) << training_objective << std::endl;
   if (halt_on_mrr_decrease > 0 && halt_on_mrr_decrease < cur_iteration && training_objective < last_training_objective)
   {
     logstream(LOG_WARNING) << "Stopping engine because of validation objective decrease" << std::endl;
     gcontext.set_last_iteration(gcontext.iteration);
   }
   logstream(LOG_DEBUG) << "after_iteration: running validation engine" << std::endl;
   run_validation(pvalidation_engine, gcontext);
   sgd_gamma *= sgd_step_dec;
 }
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:16,代码来源:climf.cpp


示例12: after_iteration

  /**
   * Called after an iteration has finished. Aggregates the model updates and
   * the evaluation measure.
   */
  void after_iteration(int iteration, graphchi_context &ginfo) {
    // TODO: to separate class?

//    std::cout << "LINREG_UPDATES:" << std::endl;
    /* Add the delta. */
    for (int i = 0; i < ginfo.execthreads; i++) {
//      std::cout << "GRADIENT" << std::endl;
//      std::cout << parallel_models[i]->str() << std::endl << std::endl;
      parallel_models[i]->update_parent(num_queries);
    }
//    std::cout << "LINREG_UPDATE AFTER ";
//    LinearRegression* lr_model = (LinearRegression*)model;
//    std::copy(lr_model->weights.begin(), lr_model->weights.end(),
//              std::ostream_iterator<double>(std::cout, " "));
//    std::cout << std::endl;

    if (phase == TRAINING || phase == VALIDATION || phase == TESTING) {
      eval->after_iteration(iteration, ginfo);

      // Debugging stuff; remove if not needed anymore.
//      std::cout << "WEIGHTS: ";
//      std::copy(((LinearRegression*)model)->weights.begin(), ((LinearRegression*)model)->weights.end(), std::ostream_iterator<double>(std::cout, " "));
//      std::cout << std::endl;
//      std::cout << "NDCG: ";
//      for (std::map<vid_t, double>::const_iterator it = eval->eval.begin();
//          it != eval->eval.end(); ++it) {
//        std::cout << it->second << " ";
//      }
//      std::copy(eval->eval.begin(), eval->eval.end(), std::ostream_iterator<double>(std::cout, " "));
//      std::cout << ", avg: " << eval->avg_eval << std::endl << std::endl;
      std::cout << "AVG NDCG: " << eval->avg_eval << std::endl;
    }

    /** Stop if the evaluation results get worse. */
    if (stop == STOP_TRAINING) {
      if (phase == TRAINING) {
        if (eval->avg_eval < last_eval_value) {
          if (last_model.get() != NULL) {
            model = last_model.release();
          }
          ginfo.set_last_iteration(ginfo.iteration);
        } else {
          last_eval_value = eval->avg_eval;
          last_model.reset(model->clone());
        }
      }
    }
  }
开发者ID:DavidNemeskey,项目名称:graphchi-ltr,代码行数:52,代码来源:ltr_algorithm.hpp


示例13: run_validation

void run_validation(graphchi_engine<VertexDataType, EdgeDataType> * pvalidation_engine, graphchi_context & context){
  //no validation data, no need to run validation engine calculations
  cur_iteration = context.iteration;
  if (pvalidation_engine == NULL)
    return;
  if (calc_ap){ //AP
    ValidationAPProgram program;
    pvalidation_engine->run(program, 1);
  }
  else { //RMSE
    ValidationRMSEProgram program;
    pvalidation_engine->run(program, 1);
  }
  if (converged_engine)
    context.set_last_iteration(context.iteration);
}
开发者ID:yangzorror,项目名称:GraduationDesign,代码行数:16,代码来源:rmse_engine.hpp


示例14: after_iteration

    /**
      * Called after an iteration has finished. Not implemented.
      */
    void after_iteration(int iteration, graphchi_context &ginfo) {
		if(iteration == 0){
			/*
			vid_t count = 1;
			std::sort(degvector.begin(), degvector.end(), sortFunc);		
			for(int i=0; i<degvector.size(); i++){
				idmap[degvector[i].vid] = count++;	
				fprintf(fp_vt, "%d\t%d\t%d\n", i, degvector[i].vid, degvector[i].deg);
			}
			fflush(fp_vt);		
			*/
			//fp_edgelist = fopen();
		}else if(iteration == 1){
			fflush(fp_metis);
			ginfo.set_last_iteration(iteration);	
		}
    }
开发者ID:warnon,项目名称:mzj_graphchi_ori,代码行数:20,代码来源:convert2Metis.cpp


示例15: before_exec_interval

 /**
  * Called before an execution interval is started.
  *
  * On every even iteration, we store pivot's adjacency lists to memory. 
  * Here we manage the memory to ensure that we do not load too much
  * edges into memory.
  */
 void before_exec_interval(vid_t window_st, vid_t window_en, graphchi_context &gcontext) {        
     if (gcontext.iteration % 2 == 0) {
         if (adjcontainer->pivot_st <= window_en) {
             size_t max_grab_edges = get_option_long("membudget_mb", 1024) * 1024 * 1024 / 8;
             if (grabbed_edges < max_grab_edges * 0.8) {
                 logstream(LOG_DEBUG) << "Window init, grabbed: " << grabbed_edges << " edges" << std::endl;
                 for(vid_t vid=window_st; vid <= window_en; vid++) {
                     gcontext.scheduler->add_task(vid);
                 }
                 adjcontainer->extend_pivotrange(window_en + 1);
                 if (window_en == gcontext.nvertices) {
                     // Last iteration needed for collecting last triangle counts
                     gcontext.set_last_iteration(gcontext.iteration + 3);                    
                 }
             } else {
                 std::cout << "Too many edges, already grabbed: " << grabbed_edges << std::endl;
             }
         }
     }
     
 }
开发者ID:Prokopp,项目名称:graphchi-cpp,代码行数:28,代码来源:trianglecounting.cpp


示例16: update

    /**
      * Pagerank update function.
      */
    void update(graphchi_vertex<VertexDataType, EdgeDataType> &v, graphchi_context &ginfo) {
        float sum=0;
	float prv = 0.0;
	float pagerankcont = 0.0;	

        if (ginfo.iteration == 0) {
            /* On first iteration, initialize vertex and out-edges. 
               The initialization is important,
               because on every run, GraphChi will modify the data in the edges on disk. 
             */
	    /* For the weighted version */
	    update_edge_data(v, 1.0, true);
            v.set_data(RANDOMRESETPROB); 
            //v.set_data(1.0); 
        } else {
	    /* We need to come up with the weighted version */
            for(int i=0; i < v.num_inedges(); i++) {
                chivector<float> * evector = v.inedge(i)->get_vector();
                assert(evector->size() >= 2);
                sum += evector->get(1);
    		//std::cout <<  v.id() << " with data: " << evector->get(1) << " with weight " << evector->get(0) << std::endl;
    		//std::cout <<  v.id() << " edge endpoint: " << v.inedge(i)->vertex_id() << std::endl;
		//evector->clear();
	    }

            /* Compute my pagerank */
            prv = RANDOMRESETPROB + (1 - RANDOMRESETPROB) * sum;
	    //std::cout << "sum" << sum << "pagerank: " << prv << std::endl;

	    update_edge_data(v, prv, false);
            /* Keep track of the progression of the computation.
               GraphChi engine writes a file filename.deltalog. */
	    double delta = std::abs(prv - v.get_data());
	    //std::cout << "pagerank: " << prv << "v.data" << v.get_data() << "delta: " << delta << std::endl;
            ginfo.log_change(delta);
            
            /* Set my new pagerank as the vertex value */
            v.set_data(prv);
        }
    }
开发者ID:carriercomm,项目名称:TrueTop,代码行数:43,代码来源:pagerank-wrong-dynamic.cpp



注:本文中的graphchi_context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ graphchi_vertex类代码示例发布时间:2022-05-31
下一篇:
C++ graph_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap