File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
examples/ScalableProblems Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,39 @@ using namespace Ipopt;
1515class RegisteredTNLP : public TNLP
1616{
1717public:
18+ RegisteredTNLP ()
19+ : interrupted_(false )
20+ { }
21+
1822 /* * Initialize internal parameters.
1923 *
2024 * @return false, if N has an invalid value
2125 */
2226 virtual bool InitializeProblem (
2327 Index N /* *< determines problems size */
2428 ) = 0;
29+
30+ bool intermediate_callback (
31+ AlgorithmMode /* mode*/ ,
32+ Index /* iter*/ ,
33+ Number /* obj_value*/ ,
34+ Number /* inf_pr*/ ,
35+ Number /* inf_du*/ ,
36+ Number /* mu*/ ,
37+ Number /* d_norm*/ ,
38+ Number /* regularization_size*/ ,
39+ Number /* alpha_du*/ ,
40+ Number /* alpha_pr*/ ,
41+ Index /* ls_trials*/ ,
42+ const IpoptData* /* ip_data*/ ,
43+ IpoptCalculatedQuantities* /* ip_cq*/
44+ )
45+ {
46+ /* returning false makes Ipopt stop */
47+ return !interrupted_;
48+ }
49+
50+ bool interrupted_;
2551};
2652
2753class RegisteredTNLPs
Original file line number Diff line number Diff line change 55// Authors: Andreas Waechter IBM 2004-11-05
66
77#include " IpIpoptApplication.hpp"
8+ #include " IpUtils.hpp"
89#include " RegisteredTNLP.hpp"
910
1011#include < cstdio>
@@ -202,7 +203,11 @@ int main(
202203 app->Options ()->SetNumericValue (" max_wall_time" , runtime);
203204#endif
204205
206+ Ipopt::RegisterInterruptHandler (NULL , &tnlp->interrupted_ );
207+
205208 status = app->OptimizeTNLP (GetRawPtr (tnlp));
206209
210+ Ipopt::UnregisterInterruptHandler ();
211+
207212 return (int ) status;
208213}
You can’t perform that action at this time.
0 commit comments