coin-or / CppAD

A C++ Algorithmic Differentiation Package: Home Page
https://cppad.readthedocs.io
Other
466 stars 94 forks source link

An exception is triggered when the program get_started.cpp runs here, see what's going on? #216

Open Wang-Peng-debug opened 2 weeks ago

Wang-Peng-debug commented 2 weeks ago

image Look! This is where the exception comes up, and the detailed is shown as follows: image Take a look where the red arrow points out, which said the exception was caused by ipopt-3.dll, but I am confused about that and I don't think so cause the example program included by IPOPT(no CppAD involving) worked very well and no any errors come up. I think perhaps this is caused by lacking of dll file of CppAD, but I am still finding the way of how to build it.

bradbell commented 1 week ago

I now have access to my windows testing machine and tried the following in a visual studio 2022 command prompt:

git clone https://github.com/coin-or/CppAD.git cppad.git
cd cppad.git
mkdir build
cmake ^
   -G "NMake Makefiles"^
   -D cppad_cxx_flags="/MP /EHs /EHc /std:c++17 /Zc:__cplusplus"^
   -D cppad_static_lib=FALSE^
   ..
nmake check

and I got the following error:

... snip ...
C:\Users\bradl\repo\cppad.git\include\cppad/local/optimize/optimize_run.hpp(332): error C2668: 'CppAD::isnan': ambiguous call to overloaded function 
... snip ...

It seems to me that (since the code is inside the CppAD name space) the CppAD isnan (instead of the std::isnan) should have been chosen.

The following seems to fix this problem: In the file

\cppad.git\include\cppad/local/optimize/optimize_run.hpp(

Changing

isnan( play->GetPar(0) )

to

CppAD::isnan( play->GetPar(0) )

There are other place that this problem occurs. I am going to create a new commit on the master branch that fixes all of them.

bradbell commented 1 week ago

@Wang-Peng-debug see the heading 09-09 on the page https://cppad.readthedocs.io/latest/2024.html#mm-dd-09-09 The Visual Studio instructions should work for you (using the most recent master branch). Please try it and report back.

Wang-Peng-debug commented 1 week ago

@Wang-Peng-debug see the heading 09-09 on the page https://cppad.readthedocs.io/latest/2024.html#mm-dd-09-09 The Visual Studio instructions should work for you (using the most recent master branch). Please try it and report back.

That's cool!!! I will give it a try, but now I'm in the middle of my work, maybe I'll do it this weekend.