コード例 #1
0
ファイル: echange_buff.c プロジェクト: anderson-abc/mdls
int main(int argc, char **argv) {

    char tmp[7];
    int n, rang, P, nbv, iv, test_msg;
    struct graphe_t graphe;
    char **msg_snd, **msg_rcv;
    int *taille_msg_snd, *taille_msg_rcv;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rang);
    MPI_Comm_size(MPI_COMM_WORLD, &P);

    lire_graphe("graphe.txt", &graphe);

    if (rang == 0)
	afficher_graphe(&graphe);

    if (P != graphe.nb_noeuds && rang == 0) {
	printf("Le nb de noeuds doit etre egal au nb de processus MPI. Nb de noeuds lus : %d\n", graphe.nb_noeuds);
	abort();
    }

    nbv = graphe.nb_voisins[rang];

    taille_msg_snd = (int*)malloc(nbv*sizeof(int));
    taille_msg_rcv = (int*)malloc(nbv*sizeof(int));
    msg_snd = (char**)malloc(nbv*sizeof(char*));
    msg_rcv = (char**)malloc(nbv*sizeof(char*));

    for( iv = 0 ; iv < nbv ; iv++ ) {
	taille_msg_snd[iv] = 7;
	taille_msg_rcv[iv] = 7;
	msg_snd[iv] = (char*)malloc(taille_msg_snd[iv]*sizeof(char));
	msg_rcv[iv] = (char*)malloc(taille_msg_rcv[iv]*sizeof(char));
	sprintf(msg_snd[iv], "S%02dD%02d", rang, graphe.voisins[rang][iv]);
    }

    echange_buffer(&graphe, msg_snd, taille_msg_snd, msg_rcv, taille_msg_rcv);

    for( iv = 0 ; iv < nbv ; iv++ ) {
	sprintf(tmp, "S%02dD%02d", graphe.voisins[rang][iv], rang);
	test_msg = (strcmp(msg_rcv[iv], tmp) == 0);
	printf("P%02d : %s : %s\n", rang, msg_rcv[iv], (test_msg ? "PASSED" : "FAILED"));
    }

    MPI_Finalize();
    return 0;
}
コード例 #2
0
ファイル: solveur_cl.cpp プロジェクト: Hagrud/Projet2
int Solveur_cl::learn_clause(vector<Clause*>& clauses, vector<Literal>& literals, vector<int>& paris){
	//Un conflit sans paris -> non satisfiable.
  if(paris.size() == 1)
      return 0;
  
  //On r?cup?re la clause du conflit.
  unsigned int conflit = get_clause_issue_id();
  
  //On construit le graphe.
  vector<vector<int>> graph(literals.size(), vector<int>());
  create_graph(clauses, literals, literals[paris.back()].getDeductions(),
               paris, graph, clauses[conflit], 0);

  //On r?cup?re l'uip.
  int uip = get_uip(graph,literals[paris.back()].getDeductions(), paris.back());

  //On affiche le graphe.
  afficher_graphe(literals, graph, literals[paris.back()].getDeductions(), uip, paris.back());
  
  //On apprend la clause.
  learn(clauses, graph, literals, literals[paris.back()].getDeductions(),uip);

  return uip;
}