Пример #1
0
int named_input_files ( void )
{
   int n, fail, len;
   char inputfile[80];
   int mode = 7;
 /* reading target system :  0 for standard, 1 for double double,
                             2 for quad double, 3 for multiprecision
    reading start system :  4 for standard, 5 for double double,
                            6 for quad double, 7 for multiprecision */

   if(mode < 4) printf("\nReading the target system from file ...\n");
   if(mode > 3) printf("\nReading the start system from file ...\n");
   printf("Give the file name : "); scanf("%s", inputfile);
   n = (int) strlen(inputfile);

   if(mode == 0)
   {
      printf("\n... test reading in standard doubles ...\n");
      fail = read_standard_target_system_from_file(n, inputfile);
      fail = copy_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_standard_target_system();
   }
   else if(mode == 1)
   {
      printf("\n... test reading in double doubles ...\n");
      fail = read_dobldobl_target_system_from_file(n, inputfile);
      fail = copy_dobldobl_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_dobldobl_target_system();
   }
   else if(mode == 2)
   {
      printf("\n... test reading in quad doubles ...\n");
      fail = read_quaddobl_target_system_from_file(n, inputfile);
      fail = copy_quaddobl_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_quaddobl_target_system();
   }
   else if(mode == 3)
   {
      printf("\n... test reading in multiprecision ...\n");
      fail = read_multprec_target_system_from_file(80, n, inputfile);
      fail = copy_multprec_container_to_target_system();
      printf("\nThe system read :\n"); fail = write_multprec_target_system();
   }
   else if(mode == 4)
   {
      printf("\n... test reading in standard doubles ...\n");
      fail = read_standard_start_system_from_file(n, inputfile);
      fail = copy_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_standard_start_system();
      fail = solcon_number_of_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else if(mode == 5)
   {
      printf("\n... test reading in double doubles ...\n");
      fail = read_dobldobl_start_system_from_file(n, inputfile);
      fail = copy_dobldobl_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_dobldobl_start_system();
      fail = solcon_number_of_dobldobl_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else if(mode == 6)
   {
      printf("\n... test reading in quad doubles ...\n");
      fail = read_quaddobl_start_system_from_file(n, inputfile);
      fail = copy_quaddobl_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_quaddobl_start_system();
      fail = solcon_number_of_quaddobl_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   else
   {
      printf("\n... test reading in multiprecision ...\n");
      fail = read_multprec_start_system_from_file(80, n, inputfile);
      fail = copy_multprec_container_to_start_system();
      printf("\nThe system read :\n"); fail = write_multprec_start_system();
      fail = solcon_number_of_multprec_solutions(&len);
      printf("\nNumber of start solutions in container : %d\n", len);
   }
   return 0;
}
Пример #2
0
void start_a_diagonal_homotopy(int myid, int numbprocs, char *name_1, 
                               char *name_2, char *outfile, WSET *ws,
                               int num_group, int stages, int cnt_stage, 
                               int cnt_step,
                               IDLE_ELEMENT **ie, LISTELEMENT **listpointer,
                               int *TaskCount, int NUM_GROUP, int NUM_VARS, 
                               int *cnt_index, int *expected,
                               int *dim, int update_flag)                           
{
   int n, deg, n1, n2, dim1, dim2, deg1, deg2, cd, nbsols,
       fail, i, slv, count;
   double vcp[34];
  
   if(myid==0)
   {
     printf("manager is in inside of start_a_diagonal_homotopy\n"); 
                           
     fail = read_two_witness_sets_from_file(&n1,&n2,&dim1,&dim2,
                                            &deg1,&deg2,name_1,name_2,&cd);
     n = cd; /* dimension */
     nbsols = deg1*deg2;
     printf("#paths to track: %d\n", nbsols);
     
     fail = define_output_file_with_string ((int)strlen(outfile), outfile);
     
     fail = standard_diagonal_homotopy(dim1,dim2);
     if(fail == 0)
     {
      fail = write_standard_target_system();
      fail = write_standard_start_system();
     }
     /*fail = tune_continuation_parameters(); printf("\n");*/
     fail = retrieve_continuation_parameters(vcp);
     write_solution_banner_to_defined_output_file(nbsols,n);
     printf("\nSee the output file %s for results...\n\n", outfile);  
     *expected = dim1+dim2-NUM_VARS;  
     printf("expected dimension=%d\n", *expected);
   }       
   
   dimension_broadcast(myid,&n);
  
   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   MPI_Bcast(vcp,34,MPI_DOUBLE,0,MPI_COMM_WORLD);
   
   if(myid != 0) 
   {
      fail = set_continuation_parameters(vcp);
   }
   
   fail = homotopy_broadcast(myid,n);
   fail = create_homotopy_with_given_gamma
                (-0.824263733224601,0.566206056211557);
   
   if(myid == 0)
   {
     send_collect(ws, num_group, stages, cnt_stage, numbprocs, cnt_step, 
                  ie, listpointer, TaskCount, NUM_GROUP,
                  cnt_index, update_flag, 
                  n1, n2, cd);
   
     if(v>3)
     {   
     printf("after send_collect \n");
     printf("%d JOBs in listpointer. \n", length(*listpointer));
     printf("%d idles\n", num_idle(*ie));
     printf("indexing........ with cnt_index=%d\n", *cnt_index);    
     }                 
   }
   else
   {   
     if(v>3) printf("node %d will run run_slave \n", myid); fflush;
     run_slave(myid); 
   }
   
   MPI_Barrier(MPI_COMM_WORLD);
                            
   if(myid == 0)
   { 
     if(v>3) printf("manager clear data \n"); 
     fail = clear_data(); 
     if(fail>0) printf("manager fail to clear data.\n"); 
     fail = clear_homotopy(); 
     if(fail>0) printf("manager fail to clear homotopy.\n"); 
     fail = solcon_close_solution_input_file(1);
     if(fail>0) printf("fail to close witness set 1.\n");
     fail = solcon_close_solution_input_file(2); 
     if(fail>0) printf("fail to close witness set 2.\n");
     fail = solcon_clear_standard_solutions( );  
     if(fail>0) printf("fail to clear solution container.\n");
     fail = close_output_file();
     if(fail>0) printf("fail to close output file. \n"); 
     fail = read_witness_set_from_file((int)strlen(outfile),
                                       outfile,&n,dim,&deg); 
     fail = solcon_clear_standard_solutions();
     fail = syscon_clear_standard_system( );
     printf("end of start_a_diagonal_homotopy\n");
     fflush;
   }
   else 
   {
     if(v>3) printf("node %d clear data.\n", myid); 
     fail = clear_data();
     if(fail>0) printf("node %d fail to clear data.\n", myid);
     fail = clear_homotopy();
     if(fail>0) printf("node %d fail to clear homotopy.\n", myid);
   }
}
Пример #3
0
void cascade_one_level_down(int myid, int numbprocs, char *infile, 
                            char *outfile, WSET *ws, int num_group, 
                            int stages, int cnt_stage, int cnt_step, IDLE_ELEMENT **ie, 
                            LISTELEMENT **listpointer, int *TaskCount,
                            int NUM_GROUP, int *dimension, int *cnt_index, 
                            int update_flag)
{
   int n,/* dimension */
       nbsols, dim, deg, fail, i,
       n1, n2, cd;   
   double vcp[34];
  
   if(myid == 0)
   {
     printf("manager is in inside of cascade_one_level_down\n");        
     read_dimension_of_system((int)strlen(infile),infile,&n);
   }
   
   dimension_broadcast(myid,&n);
   
   if(myid == 0)
   {
     fail = syscon_clear_symbol_table();
     fail = read_named_start_without_solutions((int)strlen(infile),infile);  
     /*fail = copy_start_system_to_container();*/
     fail = copy_start_system_to_container();
     fail = syscon_sort_embed_symbols(&dim);
     printf("the top dimension is %d\n",dim);
     fail = copy_container_to_start_system();
      
     fail = solcon_scan_solution_banner();
     fail = solcon_read_solution_dimensions(&nbsols,dimension); 
   }
   else
     /* initialize system container */
     fail = syscon_initialize_number_of_standard_polynomials(n);
   
   monomials_broadcast(myid,n);            /* broadcast container */

   if(myid != 0)                           /* copy result of broadcast */
   {
      fail = copy_container_to_start_system();
      fail = syscon_clear_standard_system();  /* clear system container */
   }
   
   fail = create_cascade_homotopy(); 
   
   MPI_Barrier(MPI_COMM_WORLD);
   if(myid == 0)
   {
      if(v>3) printf("# paths to track : %d\n",nbsols);
      fail = define_output_file_with_string ((int)strlen(outfile), outfile);
      
      fail = write_standard_target_system();
      fail = write_standard_start_system(); 
      /*fail = tune_continuation_parameters(); printf("\n");*/
      fail = retrieve_continuation_parameters(vcp);     
      write_solution_banner_to_defined_output_file(nbsols,n);
      printf("\nSee the output file for results...\n\n");
   }
   
   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   MPI_Bcast(vcp,34,MPI_DOUBLE,0,MPI_COMM_WORLD);
    
   if(myid != 0) 
   {
      fail = set_continuation_parameters(vcp); 
   } 
   if(myid == 0)
   {
      n1=0; n2=0; cd=n;
      send_collect(ws, num_group, stages, cnt_stage, numbprocs, cnt_step, 
                   ie, listpointer, TaskCount, NUM_GROUP,
                   cnt_index, update_flag, 
                   n1, n2, cd);  
      if(update_flag) *cnt_index=*cnt_index+1;
      
      if(v>3)
      {                         
       printf("after send_collect \n");
       printf("%d JOBs in listpointer. \n", length(*listpointer));
       printf("%d idles\n", num_idle(*ie));
       printf("indexing........ with cnt_index=%d\n", *cnt_index);  
      }                             
   }
   else
   {  
      if(v>3) printf("node %d will run run_slave \n", myid); fflush;
      run_slave(myid); 
   }
      
   MPI_Barrier(MPI_COMM_WORLD);
                          
   if(myid == 0)
   { 
      if(v>3) printf("manager clear data \n"); 
      fail = clear_data(); 
      if(fail>0) printf("manager fail to clear data.\n"); fflush;
      fail = solcon_close_solution_input_file(0);
      if(fail>0) printf("fail to close solution input file.\n");
      fail = solcon_clear_standard_solutions( );  
      if(fail>0) printf("fail to clear solution container.\n");
      fail = close_output_file();
      if(fail>0) printf("fail to close output file. \n");
      fflush;	 
   } 
   else 
   {
      if(v>3) printf("node %d clear data \n", myid); 
      fail = clear_data(); 
      if(fail>0) printf("node %d fail to clear data.\n", myid); 
      fflush; 
   }
}
Пример #4
0
int standard_run ( int myid, int nbrp, int nbc, char* outfile, int verbose )
{
   int fail,dim,nbsols,mysolnum,len,*nbpaths;
   double startwtime,endwtime,wtime,*time;

   startwtime = MPI_Wtime();
   if(myid == 0)
   {
      time = (double*)calloc(nbrp,sizeof(double));
      nbpaths = (int*)calloc(nbrp,sizeof(int));
      fail = read_target_system_without_solutions();
      fail = copy_target_system_to_container();
      fail = syscon_number_of_standard_polynomials(&dim);
      fail = write_standard_target_system(); // writes to file
   }
   standard_dimensions_broadcast(myid,&dim,&dim);

   if(verbose > 0) printf("Process %d has dimension %d.\n",myid,dim);

   monomials_broadcast(myid,dim); // broadcast target system

   if(myid != 0) fail = copy_container_to_target_system();

   if(verbose > 0)
      if(myid == 1) fail = write_standard_target_system();

   if(myid == 0)
   {
      fail = read_standard_start_system();
      fail = copy_start_system_to_container();
      fail = write_standard_start_system(); // writes to file
      fail = write_start_solutions(); // writes solutions to file
      fail = copy_start_solutions_to_container();
      fail = solcon_number_of_standard_solutions(&nbsols);
      if(verbose>0) printf("Read %d start solutions.\n",nbsols);
   }
   else
      fail = syscon_initialize_number_of_standard_polynomials(dim);

   monomials_broadcast(myid,dim); // broadcast start system

   if(myid != 0) fail = copy_container_to_start_system();

   if(verbose > 0)
      if(myid == 1) fail = write_standard_start_system();

   parameters_broadcast(myid,nbrp,verbose);

   if(myid == 0) verbose = prompt_for_verbose();
   MPI_Barrier(MPI_COMM_WORLD);

   MPI_Bcast(&verbose,1,MPI_INT,0,MPI_COMM_WORLD);

   MPI_Bcast(&nbsols,1,MPI_INT,0,MPI_COMM_WORLD);
   solutions_distribute(myid,nbsols,dim,nbrp,&mysolnum);

   fail = solcon_number_of_standard_solutions(&len);
   if(verbose > 0) printf("Node %d has %d solutions.\n",myid,len);

   if(myid > 0)
   {
      fail = copy_container_to_start_solutions();
      fail = standard_track_paths(myid,nbrp,nbc,outfile,verbose);
   }
   MPI_Barrier(MPI_COMM_WORLD);
   solutions_collect(myid,nbsols,dim,nbrp,mysolnum);

   if(myid == 0)
   {
      fail = copy_container_to_target_solutions();
      fail = write_target_solutions();
   }
   endwtime = MPI_Wtime();
   wtime = endwtime-startwtime;
   MPI_Gather(&wtime,1,MPI_DOUBLE,time,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
   MPI_Gather(&mysolnum,1,MPI_INT,nbpaths,1,MPI_INT,0,MPI_COMM_WORLD);

   if(myid == 0)
   {
      nbpaths[0] = nbsols;
      write_time_and_paths_to_defined_output_file(nbrp,time,nbpaths);
      free(time); free(nbpaths);
   }
   return 0;
}