Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfacing SPRAL with IPOPT #151

Open
bharswami opened this issue Sep 28, 2023 · 5 comments
Open

Interfacing SPRAL with IPOPT #151

bharswami opened this issue Sep 28, 2023 · 5 comments
Labels

Comments

@bharswami
Copy link

bharswami commented Sep 28, 2023

I am trying to interface SPRAL with IPOPT. I am running into some issues with getting the right output for a simple optimization problem too. The sequence of function calls that are made in IpSpralSolverInterface.cpp is:

spral_ssids_analyse_ptr32(false, ndim_, NULL, ia, ja, val_, &akeep_, &control_, &info);
spral_ssids_factor_ptr32(false, ia, ja, val_, scaling_, akeep_, &fkeep_, &control_, &info);
spral_ssids_solve(0, nrhs, rhs_vals, ndim_, akeep_, fkeep_, &control_, &info);

This is different from the calls made in ssids.c that comes with SPRAL Git repository.

/* Perform analyse and factorise with data checking */
bool check = true;
spral_ssids_analyse(check, n, NULL, ptr, row, NULL, &akeep, &options,
      &inform);
if(inform.flag<0) {
   spral_ssids_free(&akeep, &fkeep);
   exit(1);
}
spral_ssids_factor(posdef, NULL, NULL, val, NULL, akeep, &fkeep, &options,
      &inform);
if(inform.flag<0) {
   spral_ssids_free(&akeep, &fkeep);
   exit(1);
}
/* Solve */
spral_ssids_solve1(0, x, akeep, fkeep, &options, &inform);
if(inform.flag<0) {
   spral_ssids_free(&akeep, &fkeep);
   exit(1);
}

Could someone please clarify as to which function calls are more appropriate?

@jfowkes
Copy link
Contributor

jfowkes commented Sep 28, 2023

Good question, so the IPOPT interface in IpSpralSolverInterface.cpp uses more specific versions of the SSIDS functions tailored to the data types that IPOPT expects (in particular 32bit column pointers ptr and multiple right-hand sides).

The differences are essentially as follows:
spral_ssids_analyse_ptr32 - performs analyse phase for 32bit column pointers
spral_ssids_analyse - performs analyse phase for 64bit column pointers
spral_ssids_factor_ptr32 - performs factorisation for 32bit column pointers
spral_ssids_factor - performs factorisation for 64bit column pointers
spral_ssids_solve - solves for multiple right-hand sides (IPOPT)
spral_ssids_solve1 - solves for a single right-hand side (example)

For more details please see the SSIDS C documentation:
https://www.numerical.rl.ac.uk/spral/doc/latest/C/ssids.html

@bharswami
Copy link
Author

The SPRAL solver interface file has the ptr32 functions. Is it because the code is old?

@jfowkes
Copy link
Contributor

jfowkes commented Sep 28, 2023

I think it's more likely that IPOPT use 32bit integers to index sparse matrices, you need to have a really large matrix to need 64bits, as in ptr would need to hold more than 2,147,483,647 entries! Matrices of that size are unlikely to arise in interior point problems.

@bharswami
Copy link
Author

I am trying to run simple optimization problems with ipopt and spral. I am encountering lot of NaNs and infs.
I have no idea what both the codes do. Is there someone who can help me out a bit so that I can fix these issues?

@jfowkes
Copy link
Contributor

jfowkes commented Oct 3, 2023

I suggest you ask for help on the IPOPT GitHub, SPRAL is just a linear system solver that is used to solver the interior point linear systems that arise within IPOPT. For more on interior point see:
https://en.wikipedia.org/wiki/Interior-point_method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants