libprima / prima

PRIMA is a package for solving general nonlinear optimization problems without using derivatives. It provides the reference implementation for Powell's derivative-free optimization methods, i.e., COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA. PRIMA means Reference Implementation for Powell's methods with Modernization and Amelioration, P for Powell.
http://libprima.net
BSD 3-Clause "New" or "Revised" License
290 stars 35 forks source link

Update the signature of prima_minimize #173

Closed amontoison closed 3 months ago

amontoison commented 3 months ago

@zaikunzhang Note that I removed these checks because we can't have anymore null pointers for the problem or the options.

if (!problem)
        return PRIMA_NULL_PROBLEM;

and

if (!options)
        return PRIMA_NULL_OPTIONS;

It also means that the argument options is not used anymore in prima_check_problem.

zaikunzhang commented 3 months ago

@zaikunzhang Note that I removed these checks because we can't have anymore null pointers for the problem or the options.

if (!problem)
        return PRIMA_NULL_PROBLEM;

and

if (!options)
        return PRIMA_NULL_OPTIONS;

It also means that the argument options is not used anymore in prima_check_problem.

Thank you @amontoison for the quick action!

I agree with what you mentioned above.

What about adding const to problem and options wherever possible? For example, change

int prima_minimize(const prima_algorithm_t algorithm, prima_problem_t problem, prima_options_t options, prima_result_t *const result);

to

int prima_minimize(const prima_algorithm_t algorithm, const prima_problem_t problem, const prima_options_t options, prima_result_t *const result);

Thank you.

amontoison commented 3 months ago

What about adding const to problem and options wherever possible? For example, change

int prima_minimize(const prima_algorithm_t algorithm, prima_problem_t problem, prima_options_t options, prima_result_t *const result);

to

int prima_minimize(const prima_algorithm_t algorithm, const prima_problem_t problem, const prima_options_t options, prima_result_t *const result);

I forgot to add these const. It should be fixed the last commit that I pushed :+1: