IPOPT Options Not Settable in Visual Studio 2022 Release Configuration

65 Views Asked by At

I am currently working on an optimization problem using IPOPT in C++ with Visual Studio 2022. I am using the HS071_NLP example provided by IPOPT and I want to limit the number of iterations using the following code:


#include "IpIpoptApplication.hpp"
#include "hs071_nlp.hpp"
#include "ipoptOptimizer.h"
#include <iostream>

using namespace Ipopt;

int main()
{
   SmartPtr<TNLP> mynlp = new HS071_NLP();
   SmartPtr<IpoptApplication> app = IpoptApplicationFactory();

   Ipopt::SmartPtr<Ipopt::OptionsList> options_list = app->Options();

   try {
        app->Options()->SetIntegerValue("max_iter", 500);
    }
    catch (std::exception  e) {
        std::cerr << "Exception while setting max_iter: " << e.what() << std::endl;
        return 1;
    }


   ApplicationReturnStatus status;
   status = app->Initialize();
   if( status != Solve_Succeeded )
   {
      std::cout << std::endl << std::endl << "*** Error during initialization!" << std::endl;
      return (int) status;
   }

   status = app->OptimizeTNLP(mynlp);

   if( status == Solve_Succeeded )
   {
      std::cout << std::endl << std::endl << "*** The problem solved!" << std::endl;
   }
   else
   {
      std::cout << std::endl << std::endl << "*** The problem FAILED!" << std::endl;
   }

   return (int) status;
}

The code works fine when I comment out this line:

// app->Options()->SetIntegerValue("max_iter", 50);

But when I uncomment it, I receive the following output:

Tried to set Option: └t♂ä█uHç§zJ. It is not a valid option. Please check the list of available options.

Additionally, nothing else changes, and the optimization continues after 50 iterations.

Here are some additional details:

  • I downloaded the IPOPT library IPOPT-3.14.12-win64-msvs2019-mdd.zip from this [link:https://github.com/coin-or/Ipopt/releases/tag/releases%2F3.14.12]
  • I am using the release configuration for my solution.

I would appreciate any insights or suggestions on how to resolve this issue and successfully set the maximum number of iterations in my IPOPT optimization.

Thank you!

1

There are 1 best solutions below

0
alex grn On

There are two redistributable versions of IPOPT, zip-compressed files, one is for release configuration, with -md suffix and the other is for debug, with -mdd suffix. Use them appropriately.