Ejemplo n.º 1
0
int main(int argc, char* argv[]) {
	MPI_Init(&argc, &argv);
	PAR_DEBUG("start");
	MPI_Comm comm = MPI_COMM_WORLD;
	MPI_Comm_rank(comm, &gmyid);
	MPI_Comm_size(comm, &gnprocs);

	str_init_x0_cb init_x0 = &str_init_x0;
	str_prob_info_cb prob_info = &str_prob_info;
	str_eval_f_cb eval_f = &str_eval_f;
	str_eval_g_cb eval_g = &str_eval_g;
	str_eval_grad_f_cb eval_grad_f = &str_eval_grad_f;
	str_eval_jac_g_cb eval_jac_g = &str_eval_jac_g;
	str_eval_h_cb eval_h = &str_eval_h;
	str_write_solution_cb write_solution = &str_write_solution;

	PipsNlpProblemStructPtr prob = CreatePipsNlpProblemStruct(MPI_COMM_WORLD, 2,
			init_x0, prob_info, eval_f, eval_g, eval_grad_f, eval_jac_g,
			eval_h, write_solution, NULL);

	PAR_DEBUG("problem created");

	PipsNlpSolveStruct(prob);

	PAR_DEBUG("end solve ");
	MPI_Barrier(comm);
}
Ejemplo n.º 2
0
int main(int argc, char* argv[]) {
  MPI_Init(&argc, &argv);
  MESSAGE("start");
  MPI_Comm comm = MPI_COMM_WORLD;
  MPI_Comm_rank(comm, &gmyid);
  MPI_Comm_size(comm, &gnprocs);
  
  str_init_x0_cb init_x0 = &str_init_x0;
  str_prob_info_cb prob_info = &str_prob_info;
  str_eval_f_cb eval_f = &str_eval_f;
  str_eval_g_cb eval_g = &str_eval_g;
  str_eval_grad_f_cb eval_grad_f = &str_eval_grad_f;
  str_eval_jac_g_cb eval_jac_g = &str_eval_jac_g;
  str_eval_h_cb eval_h = &str_eval_h;
  str_write_solution_cb write_solution = &str_write_solution;
  
  PipsNlpProblemStructPtr prob = 
    CreatePipsNlpProblemStruct(MPI_COMM_WORLD, 2,
			       init_x0, prob_info, eval_f, eval_g, eval_grad_f, eval_jac_g,
			       eval_h, write_solution, NULL);
  
  MESSAGE("problem created");
  
  PipsNlpSolveStruct(prob);

  // here is the 'TESTING' behaviour, when -objcheck is passed
  int nreturn=0; //=OK, be optimistic
  if(argc>1) {
    if(objCheckArgName==argv[1]) {
      double objective = PipsNlpProblemStructGetObjective(prob);
      if(fabs((objective-optObj)/(1+optObj))>1e-5)
	nreturn=-1; //failure, didn't get 5 common digits
      std::cout << "Objective should be " <<  optObj << " and we got " << objective << std::endl;
    } else {
      std::cout << "Couldn't understand option option [" << argv[1] << "]" << std::endl;
    }
  }

  //! should have a deallocation of 'prob' here...

  MESSAGE("end solve ");
  MPI_Barrier(comm);
  MPI_Finalize();

  return nreturn;
}