Beispiel #1
0
int user_send_lp_data(void *user, void **user_lp)
{
   /* This gives you access to the user data structure. */
   spp_problem *spp = (spp_problem *) user;
   col_ordered *m = spp->cmatrix;

#if defined(COMPILE_IN_TM) && defined(COMPILE_IN_LP)
   
   spp_lp_problem *spp_lp = (spp_lp_problem *)
      calloc(1, sizeof(spp_lp_problem));
   *user_lp = (void *) spp_lp;

   spp_lp->par = spp->lp_par;
   spp_lp->cmatrix = m;

   /* initialize some data structures in spp */
   spp_init_lp(spp_lp);

#else
   /* Here, we send that data using message passing and the rest is
      done in user_receive_lp_data() in the LP process */

   send_char_array((char *)spp->lp_par, sizeof(spp_lp_params));
   send_int_array(&m->colnum, 1);
   send_int_array(&m->rownum, 1);
   send_int_array(&m->nzcnt, 1);
   send_int_array(m->colnames, m->colnum);
   send_dbl_array(m->obj, m->colnum);
   send_int_array(m->matbeg, (m->colnum + 1));
   send_char_array((char *)m->matind, m->nzcnt * sizeof(row_ind_type));
   
#endif

   return(USER_SUCCESS);
}
Beispiel #2
0
int user_send_cg_data(void *user, void **user_cg)
{
   spp_problem *spp = (spp_problem *)user;
   col_ordered *m = spp->cmatrix;
   int colnum = m->colnum;

#if defined(COMPILE_IN_TM) && defined(COMPILE_IN_LP) && defined (COMPILE_IN_CG)

   spp_cg_problem *spp_cg = (spp_cg_problem *)calloc(1,sizeof(spp_cg_problem));
   *user_cg = (void *) spp_cg;

   spp_cg->par = spp->cg_par;
   spp_cg->cmatrix = m;
   
   /* allocate space for tmp arrays */
   spp_cg->tmp = (spp_cg_tmp *) calloc(1, sizeof(spp_cg_tmp));
   spp_cg->tmp->itmp_m = (int *) malloc(m->rownum * ISIZE);
   spp_cg->tmp->istartmp_m = (int **) malloc(m->rownum * sizeof(int *));
   spp_cg->tmp->cuttmp = (cut_data *) calloc(1, sizeof(cut_data));

   /* initialize cg data structures */
   spp_cg->fgraph = (frac_graph *) calloc(1, sizeof(frac_graph));
   spp_cg->cfgraph = (frac_graph *) calloc(1, sizeof(frac_graph));
   spp_cg->cm_frac = (col_ordered *) calloc(1, sizeof(col_ordered));
   spp_cg->rm_frac = (row_ordered *) calloc(1, sizeof(row_ordered));
   spp_cg->rm_frac->rmatbeg = (int *) malloc((m->rownum+1) * ISIZE);
   spp_cg->lgraph = (level_graph *) calloc(1, sizeof(level_graph));

   allocate_var_length_structures(spp_cg, spp_cg->max_sol_length);
   
   /* cut collection is a local cut pool that contains the cuts that have
      been sent back to the lp */
   spp_cg->cut_coll = (cut_collection *) calloc(1, sizeof(cut_collection));
   spp_cg->cut_coll->max_size = 1000;
   spp_cg->cut_coll->cuts = (cut_data **) calloc(spp_cg->cut_coll->max_size,
						 sizeof(cut_data *));
   spp_cg->cut_coll->violation = (double *)
      malloc(spp_cg->cut_coll->max_size * DSIZE);
   spp_cg->cut_coll->mult = (int *)
      malloc(spp_cg->cut_coll->max_size * ISIZE);
   
#else

   int info;

   send_char_array((char *)spp->cg_par, sizeof(spp_cg_params));
   send_int_array(&colnum, 1);
   send_int_array(&m->rownum, 1);
   send_int_array(&m->nzcnt, 1);
   send_int_array(m->colnames, colnum);
   send_dbl_array(m->obj, colnum);
   send_int_array(m->matbeg, colnum + 1);
   send_char_array((char *)m->matind, m->nzcnt * sizeof(row_ind_type));

#endif

   return(USER_SUCCESS);
}
Beispiel #3
0
int send_cp_data_u(sym_environment *env, int sender)
{
#if defined(COMPILE_IN_TM) && defined(COMPILE_IN_CP)
   int i;
   tm_prob *tm = env->tm;

   tm->cpp = (cut_pool **) malloc(env->par.tm_par.max_cp_num*sizeof(cut_pool *));
   for (i = 0; i < env->par.tm_par.max_cp_num; i++){
      tm->cpp[i] = (cut_pool *) calloc(1, sizeof(cut_pool));
      tm->cpp[i]->par = env->par.cp_par;
#ifdef USE_SYM_APPLICATION
      CALL_USER_FUNCTION( user_send_cp_data(env->user, &env->tm->cpp[i]->user) );
#endif
   }
#else
   int s_bufid;

   s_bufid = init_send(DataInPlace);
   send_char_array((char *)(&env->par.cp_par), sizeof(cp_params));
#ifdef USE_SYM_APPLICATION
   CALL_USER_FUNCTION( user_send_cp_data(env->user, NULL) );
#endif
   send_msg(sender, CP_DATA);
   freebuf(s_bufid);
#endif

   return(FUNCTION_TERMINATED_NORMALLY);
}
Beispiel #4
0
int send_cg_data_u(sym_environment *env, int sender)
{
#if defined(COMPILE_IN_TM) && defined(COMPILE_IN_LP) && defined(COMPILE_IN_CG)
   int i;
   tm_prob *tm = env->tm;
   tm->cgp = (cg_prob **) malloc(tm->par.max_active_nodes*sizeof(cg_prob *));
#pragma omp parallel for
   for (i = 0; i < tm->par.max_active_nodes; i++){
      tm->lpp[i]->cgp = tm->cgp[i] = (cg_prob *) calloc(1, sizeof(cg_prob));
      
      tm->cgp[i]->par = env->par.cg_par;
      
      tm->cgp[i]->draw_graph = env->dg_tid;
#ifdef USE_SYM_APPLICATION      
      CALL_USER_FUNCTION( user_send_cg_data(env->user,
					    &(tm->lpp[i]->cgp->user)) );
#endif
   }
#else
   int s_bufid;

   s_bufid = init_send(DataInPlace);
   send_char_array((char *)(&env->par.cg_par), sizeof(cg_params));
   send_int_array(&env->dg_tid, 1);
#ifdef USE_SYM_APPLICATION
   CALL_USER_FUNCTION( user_send_cg_data(env->user, NULL) );
#endif
   send_msg(sender, CG_DATA);
   freebuf(s_bufid);
#endif

   return(FUNCTION_TERMINATED_NORMALLY);
}
Beispiel #5
0
void lp_close(lp_prob *p)
{
#ifndef COMPILE_IN_LP
   int s_bufid;
   
   /* Send back the timing data for the whole algorithm */
   s_bufid = init_send(DataInPlace);
   send_char_array((char *)&p->comp_times, sizeof(node_times));
   send_msg(p->tree_manager, LP__TIMING);
   freebuf(s_bufid);
#else
#pragma omp critical (timing_update)
{
   p->tm->comp_times.communication    += p->comp_times.communication;
   p->tm->comp_times.lp               += p->comp_times.lp;
   p->tm->comp_times.separation       += p->comp_times.separation;
   p->tm->comp_times.fixing           += p->comp_times.fixing;
   p->tm->comp_times.pricing          += p->comp_times.pricing;
   p->tm->comp_times.strong_branching += p->comp_times.strong_branching;
}
#endif
#ifdef COMPILE_IN_CG
   cg_close(p->cgp);
#endif
#ifndef COMPILE_IN_TM
   free_lp(p);
#endif
}
Beispiel #6
0
void INTERMED_ERROR(char *window_name, int old_msgtag,
		    int receiver, int msgtag)
{
   int s_bufid;
   s_bufid = init_send(DataInPlace);
   send_char_array(window_name, MAX_NAME_LENGTH);
   send_int_array(&old_msgtag, 1);
   send_msg(receiver, msgtag);
   freebuf(s_bufid);
}
Beispiel #7
0
void pack_basis(basis_desc *basis, char explicit_packing)
{
   send_char_array(&basis->basis_exists, 1);
   if (basis->basis_exists){
      pack_double_array_desc(&basis->baserows, explicit_packing);
      pack_double_array_desc(&basis->extrarows, explicit_packing);
      pack_double_array_desc(&basis->basevars, explicit_packing);
      pack_double_array_desc(&basis->extravars, explicit_packing);
   }
}
Beispiel #8
0
void pack_double_array_desc(double_array_desc *dad, char explicit_packing)
{
   send_char_array(&dad->type, 1);
   send_int_array(&dad->size, 1);
   if (dad->size > 0){
      if (!explicit_packing && dad->type == WRT_PARENT)
	 send_int_array(dad->list, dad->size);
      send_int_array(dad->stat, dad->size);
   }
}
Beispiel #9
0
int init_draw_graph_u(sym_environment *env)
{
   if (env->par.do_draw_graph){ /*start up the graphics window*/
      int s_bufid;
      if (env->par.dg_machine_set){
	 spawn(env->par.dg_exe, (char **)NULL, env->par.dg_debug | TaskHost,
	       env->par.dg_machine, 1, &env->dg_tid);
      }else{
	 spawn(env->par.dg_exe, (char **)NULL, env->par.dg_debug, (char *)NULL, 1,
	       &env->dg_tid);
      }
      s_bufid = init_send(DataInPlace);
      send_char_array((char *)&env->par.dg_par, sizeof(dg_params));
      send_msg(env->dg_tid, DG_DATA);
      freebuf(s_bufid);

#ifdef USE_SYM_APPLICATION
      if (env->dg_tid)
	 CALL_USER_FUNCTION( user_init_draw_graph(env->user, env->dg_tid) );
#endif
   }

   return(FUNCTION_TERMINATED_NORMALLY);
}
Beispiel #10
0
int send_lp_data_u(sym_environment *env, int sender)
{
#if defined(COMPILE_IN_TM) && defined(COMPILE_IN_LP)
   int i;
   tm_prob *tm = env->tm;
   tm->par.max_active_nodes = env->par.tm_par.max_active_nodes;
#ifdef _OPENMP
   omp_set_dynamic(FALSE);
   omp_set_num_threads(tm->par.max_active_nodes);
#else
   tm->par.max_active_nodes = 1;
#endif

   tm->lpp = (lp_prob **) malloc(tm->par.max_active_nodes * sizeof(lp_prob *));

#pragma omp parallel for
   for (i = 0; i < tm->par.max_active_nodes; i ++){
      tm->lpp[i] = (lp_prob *) calloc(1, sizeof(lp_prob));
      tm->lpp[i]->proc_index = i;
      tm->lpp[i]->par = env->par.lp_par;

      if ((tm->lpp[i]->has_ub = env->has_ub)){
	 tm->lpp[i]->ub = env->ub;
      }else{
	 env->ub = - (MAXDOUBLE / 2);
      }
      if (env->par.multi_criteria){
	 if ((tm->lpp[i]->has_mc_ub = env->has_mc_ub)){
	    tm->lpp[i]->mc_ub = env->mc_ub;
	    tm->lpp[i]->obj[0] = env->obj[0];
	    tm->lpp[i]->obj[1] = env->obj[1];
	 }else{
	    env->mc_ub = - (MAXDOUBLE / 2);
	 }
	 tm->lpp[i]->utopia[0] = env->utopia[0];
	 tm->lpp[i]->utopia[1] = env->utopia[1];
      }
      tm->lpp[i]->draw_graph = env->dg_tid;
      tm->lpp[i]->base = *(env->base);
      tm->lpp[i]->mip = env->mip;

#ifdef USE_SYM_APPLICATION
      CALL_USER_FUNCTION( user_send_lp_data(env->user, &(tm->lpp[i]->user)) );
#endif
   }
#else   
   int s_bufid;

   s_bufid = init_send(DataInPlace);
   send_char_array((char *)(&env->par.lp_par), sizeof(lp_params));
   send_char_array(&env->has_ub, 1);
   if (env->has_ub)
      send_dbl_array(&env->ub, 1);
   if (env->par.multi_crtieria){
      send_char_array(&env->has_mc_ub, 1);
      if (env->has_mc_ub){
	 send_dbl_array(&env->mc_ub, 1);
	 send_dbl_array(env->obj, 2);
      }
      send_dbl_array(env->utopia, 2);
   }
   send_int_array(&env->dg_tid, 1);
   send_int_array(&env->base->varnum, 1);
   if (env->base->varnum){
      send_int_array(env->base->userind, env->base->varnum);
   }
   send_int_array(&env->base->cutnum, 1);
   if (env->mip){
      MIPdesc *mip = env->mip;
      char has_desc = TRUE;
      char has_colnames = FALSE;
      send_char_array(&has_desc, 1);
      send_int_array(&(mip->m), 1);
      send_int_array(&(mip->n), 1);
      send_int_array(&(mip->nz), 1);
      send_char_array(&(mip->obj_sense), 1);
      send_dbl_array(&(mip->obj_offset), 1);
      send_int_array(mip->matbeg, mip->n);
      send_int_array(mip->matind, mip->nz);
      send_dbl_array(mip->matval, mip->nz);
      send_dbl_array(mip->obj, mip->n);
      if (env->par.multi_criteria){
	 send_dbl_array(mip->obj, mip->n);
	 send_dbl_array(mip->obj2, mip->n);
      }
      send_dbl_array(mip->rhs, mip->m);
      send_char_array(mip->sense, mip->m);
      send_dbl_array(mip->rngval, mip->m);
      send_dbl_array(mip->ub, mip->n);
      send_dbl_array(mip->lb, mip->n);
      send_char_array(mip->is_int, mip->n);
      if (mip->colname){
	 int i;
	 has_colnames = TRUE;
	 send_char_array(&has_colnames, 1);
	 for (i = 0; i < mip->n; i++){
	    send_char_array(mip->colname[i], 8);
	 }
      }else{
	 send_char_array(&has_colnames, 1);
      }	 
   }else{
      char has_desc = FALSE;
      send_char_array(&has_desc, 1);
   }
#ifdef USE_SYM_APPLICATION
   CALL_USER_FUNCTION( user_send_lp_data(env->user, NULL) );
#endif
   send_msg(sender, LP_DATA);
   freebuf(s_bufid);
#endif

   return(FUNCTION_TERMINATED_NORMALLY);
}
Beispiel #11
0
void pack_cut(cut_data *cut)
{
   send_char_array((char *)cut, sizeof(cut_data));
   if (cut->size > 0)
      send_char_array(cut->coef, cut->size);
}
Beispiel #12
0
void pack_array_desc(array_desc *adesc)
{
   send_char_array((char *)adesc, sizeof(array_desc));
   if (adesc->type != NO_DATA_STORED && adesc->size > 0)
      send_int_array(adesc->list, adesc->size);
}