Go to the documentation of this file.
26 #define mango_interface_string_length 256
45 std::cout <<
"interface.cpp subroutine mango_problem_create: objective_function=" << (
long int)objective_function << std::endl;
47 std::cout <<
"From interface.cpp, N_parameters=" << *N_parameters;
48 for (
int j=0; j<*N_parameters; j++) {
49 std::cout <<
", state_vector["<<j<<
"]=" << state_vector[j];
60 return new mango::Problem(*N_parameters, state_vector, objective_function, 0, NULL);
66 return new mango::Least_squares_problem(*N_parameters, state_vector, *N_terms, targets, sigmas, best_residual_function, residual_function, 0, NULL);
97 This->
mpi_partition.
set_custom(MPI_Comm_f2c(*comm_world), MPI_Comm_f2c(*comm_group_leaders), MPI_Comm_f2c(*comm_worker_groups));
181 if (*centered_differences_int==1) {
183 }
else if (*centered_differences_int==0) {
186 throw std::runtime_error(
"Error in interface.cpp mango_set_centered_differences");
193 return(return_bool ? 1 : 0);
209 if (*print_residuals_in_output_file_int==1) {
211 }
else if (*print_residuals_in_output_file_int==0) {
214 throw std::runtime_error(
"Error in interface.cpp mango_set_print_residuals_in_output_file");
232 return (return_bool ? 1 : 0);
240 if (*preserve_sign != 0 && *preserve_sign != 1)
throw std::runtime_error(
"preserve_sign should be 0 or 1.");
void set_N_worker_groups(int N_worker_groups)
Set the number of worker groups to the given integer.
void mango_mpi_partition_write(mango::Problem *This, char filename[mango_interface_string_length])
void mango_set_algorithm_from_string(mango::Problem *This, char algorithm_name[mango_interface_string_length])
int mango_get_mpi_comm_worker_groups(mango::Problem *This)
int mango_get_function_evaluations(mango::Problem *This)
void set_N_line_search(int N_line_search)
Sets the number of points considered as a set for parallel line searches.
void stop_workers()
Tell the worker MPI processes (i.e. those that are not group leaders) that the optimization problem i...
void mango_set_bound_constraints(mango::Problem *This, double *lower_bounds, double *upper_bounds)
void set_print_residuals_in_output_file(bool print)
Determine whether or not to print each individual residual in the MANGO output file.
#define mango_interface_string_length
void mango_read_input_file(mango::Problem *This, char filename[mango_interface_string_length])
void mango_set_output_filename(mango::Problem *This, char filename[mango_interface_string_length])
void mango_set_verbose(mango::Problem *This, int *verbose)
void mango_set_centered_differences(mango::Problem *This, int *centered_differences_int)
MPI_Comm get_comm_world()
Get the MPI communicator for MANGO's world communicator.
bool get_proc0_worker_groups()
Determine whether this MPI processor has rank 0 in MANGO's "worker groups" communicator.
void mango_set_N_worker_groups(mango::Problem *This, int *N_worker_groups)
MPI_Comm get_comm_group_leaders()
Get the MPI communicator for MANGO's "group leaders" communicator.
int get_N_parameters()
Get the number of independent variables for an optimization problem.
void set_user_data(void *user_data)
Pass the prescribed pointer to the objective function whenever it is called.
int mango_get_N_procs_group_leaders(mango::Problem *This)
bool does_algorithm_exist(std::string algorithm_name)
Checks whether or not a string corresponds to the name of one of the optimization algorithms known by...
void mango_mpi_partition_set_custom(mango::Problem *This, MPI_Fint *comm_world, MPI_Fint *comm_group_leaders, MPI_Fint *comm_worker_groups)
MPI_Partition mpi_partition
algorithm_type
A list of the algorithms that MANGO can potentially use.
void mango_stop_workers(mango::Problem *This)
void mango_set_relative_bound_constraints(mango::Problem *This, double *min_factor, double *max_factor, double *min_radius, int *preserve_sign)
int get_worker_group()
Returns an integer indicating the worker group to which this MPI process belongs.
int mango_get_mpi_rank_world(mango::Problem *This)
int mango_get_mpi_rank_group_leaders(mango::Problem *This)
void mango_set_finite_difference_step_size(mango::Problem *This, double *step)
void set_max_function_evaluations(int N)
Set the maximum number of evaluations of the objective function that will be allowed before the optim...
void set_verbose(int verbose)
Control how much diagnostic information is printed by MANGO.
void set_custom(MPI_Comm comm_world, MPI_Comm comm_group_leaders, MPI_Comm comm_worker_groups)
Use a user-supplied partitioning of the MPI processes into worker groups.
int get_best_function_evaluation()
For an optimization problem that has already been solved, return the index of the function evaluation...
void set_algorithm(algorithm_type algorithm)
Sets the optimization algorithm.
void mango_set_user_data(mango::Problem *This, void *user_data)
void(* vector_function_type)(int *N_parameters, const double *state_vector, int *N_terms, double *residuals, int *failed, mango::Problem *problem, void *user_data)
Format for the user-supplied subroutine that computes the residuals for a least-squares optimization ...
void set_output_filename(std::string filename)
Sets the name of the output file that will record values of the objective function at each evaluation...
int mango_get_proc0_worker_groups(mango::Problem *This)
mango::Problem * mango_problem_create(int *N_parameters, double *state_vector, mango::objective_function_type objective_function)
void set_centered_differences(bool centered_differences)
Control whether 1-sided or centered finite differences will be used to compute derivatives of the obj...
void mango_problem_destroy(mango::Problem *This)
int mango_get_best_function_evaluation(mango::Problem *This)
int mango_continue_worker_loop(mango::Problem *This)
int get_rank_group_leaders()
Get the MPI rank of this processor in MANGO's "group leaders" communicator.
void set_finite_difference_step_size(double finite_difference_step_size)
Set an absolute step size for finite difference derivatives.
int get_N_procs_group_leaders()
Get the number of processors in MANGO's "group leaders" communicator.
int get_N_procs_worker_groups()
Get the number of processors in MANGO's "worker groups" communicator.
int mango_get_N_procs_world(mango::Problem *This)
int get_rank_world()
Get the MPI rank of this processor in MANGO's world communicator.
void(* objective_function_type)(int *N_parameters, const double *state_vector, double *objective_value, int *failed, mango::Problem *problem, void *user_data)
Format for the user-supplied subroutine that computes the objective function for a general (non least...
void mango_set_max_function_evaluations(mango::Problem *This, int *N)
mango::Least_squares_problem * mango_problem_create_least_squares(int *N_parameters, double *state_vector, int *N_terms, double *targets, double *sigmas, double *best_residual_function, mango::vector_function_type residual_function)
int mango_get_mpi_comm_world(mango::Problem *This)
int mango_get_N_terms(mango::Least_squares_problem *This)
bool get_proc0_world()
Determine whether this MPI processor has rank 0 in MANGO's world communicator.
int mango_does_algorithm_exist(char algorithm_name[mango_interface_string_length])
int get_N_worker_groups()
Returns the number of worker groups.
void mango_set_N_line_search(mango::Problem *This, int *N)
int mango_get_mpi_comm_group_leaders(mango::Problem *This)
int get_rank_worker_groups()
Get the MPI rank of this processor in MANGO's "worker groups" communicator.
int mango_get_mpi_rank_worker_groups(mango::Problem *This)
void mango_set_print_residuals_in_output_file(mango::Least_squares_problem *This, int *print_residuals_in_output_file_int)
int mango_get_worker_group(mango::Problem *This)
MPI_Comm get_comm_worker_groups()
Get the MPI communicator for MANGO's "worker groups" communicator.
void mpi_init(MPI_Comm mpi_comm)
Initialize MANGO's internal MPI data that describes the partitioning of the processes into worker gro...
void set_relative_bound_constraints(double min_factor, double max_factor, double min_radius, bool preserve_sign)
Impose bound constraints on an optimization problem, with the bounds chosen as multiples of the initi...
int mango_get_N_parameters(mango::Problem *This)
int get_function_evaluations()
For an optimization problem that has already been solved, return the number of times the objective fu...
void mobilize_workers()
Tell the worker MPI processes (i.e. those that are not group leaders) to begin an evaluation of the o...
bool continue_worker_loop()
For an MPI worker, determine whether to carry out another evaluation of the objective function or exi...
int get_N_terms()
Return the number of least-squares terms that are summed to form the objective function.
int mango_get_N_worker_groups(mango::Problem *This)
void read_input_file(std::string filename)
Reads in the number of worker groups and algorithm from a file.
double optimize()
Solve the optimization problem that has been set up.
int get_N_procs_world()
Get the number of processors in MANGO's world communicator.
void mango_mobilize_workers(mango::Problem *This)
int mango_get_proc0_world(mango::Problem *This)
void mango_set_algorithm(mango::Problem *This, mango::algorithm_type *algorithm)
void write(std::string filename)
Write a file with the given filename, showing the worker group assignments and rank of each process i...
double mango_optimize(mango::Problem *This)
int mango_get_N_procs_worker_groups(mango::Problem *This)
void set_bound_constraints(double *lower, double *upper)
Sets bound constraints for the optimization problem.
void mango_mpi_init(mango::Problem *This, MPI_Fint *comm)