Skip to content

Commit

Permalink
240409.121651.HKT update the comments about problem.f0 and `problem…
Browse files Browse the repository at this point in the history
….nlconstr0`
  • Loading branch information
zaikunzhang committed Apr 9, 2024
1 parent ae9c559 commit 2eab30c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions c/examples/cobyla/cobyla_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ int main(int argc, char * argv[])
problem.calcfc = &fun;
// Provide the initial values of the objective function and the nonlinear constraints.
// This is OPTIONAL, and end users should NOT do it in general. Here, we do it for testing.
// problme.f0 and problem.nlconstr0 are used when interfacing with Python and Julia etc.
// They are not designed for C users.See the documentation of `prima_problem_t` for details.
#if PROVIDE_INITIAL_F_AND_NLCONSTR
double nlconstr0[M_NLCON] = {0};
fun(x0, &(problem.f0), nlconstr0, NULL);
Expand Down
13 changes: 9 additions & 4 deletions c/include/prima/prima.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,20 @@ typedef struct {
double *Aeq;
double *beq;

// m_nlcon: number of nonlinear constraints
// m_nlcon: number of nonlinear constraints defined by calcfc
// Should be 0 for UOBYQA, NEWUOA, BOBYQA, and LINCOA
// Default: 0
int m_nlcon;

// f0, nlconstr0: initial objective function value and constraint values (COBYLA only)
// Should ONLY be used when interfacing with MATLAB/Python/Julia/R, where we need to evaluate
// the constraints at the initial point to get m_nlcon
// C end users should leave them as the default, i.e., f0 = NAN and nlconstr0 = NULL.
// It should ONLY be used when interfacing with high-level languages such as MATLAB/Python/
// Julia/R. In these languages, instead of asking the user to provide m_nlcon, we should
// evaluate the constraints at the initial point to get m_nlcon; we evaluate the objective
// function at the initial point as well to keep the objective and constraint evaluations
// synchronized; after this, we pass the initial object and constraint values to the solver
// via f0 and nlconstr0 to avoid re-evaluating them, as the evaluations are expensive.
// C end users should leave f0 and nlconstr0 as the default set by prima_init_problem and
// set m_nlcon to the number of nonlinear constraints.
// Default: f0 = NAN and nlconstr0 = NULL
double f0;
double *nlconstr0;
Expand Down

1 comment on commit 2eab30c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (1)

problme

To accept these unrecognized words as correct, you could run the following commands

... in a clone of the [email protected]:libprima/prima.git repository
on the main branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/libprima/prima/actions/runs/8610242249/attempts/1'
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.