ipopt and cppad tests, error from a known source #226
Replies: 11 comments
-
The error message is
The best way to debug this is the build a debugging version of your program, run in the debugger, and when the error occurs, go up the stack to find the vector that is smaller than the requested index. Please try this and report back what you find out. |
Beta Was this translation helpful? Give feedback.
-
Hello, I ran it on arm architecture, and found that the problem appeared in the solution step. It was found that the following statement made it impossible to execute. |
Beta Was this translation helpful? Give feedback.
-
I think that if you ran your program in the debugger, you would find that the vector index failure is at the line
because the vector solution.x is empty. If this is so, it is s probably because ipopt returns a failure status value; i.e.,
is false. Check what the value of solution.status is. Perhaps setting print_level to 5 in the line
will give you more information. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Error from an unknown source means that there is an unknown problem on your system. Try running your program using valgrind; |
Beta Was this translation helpful? Give feedback.
-
The example code above does not compile. When I fix the first include I get the error: AD must have a template argument; e.g. |
Beta Was this translation helpful? Give feedback.
-
Hello, there is no problem with my program. There is a problem with an mpc program. I wonder if you can compile it. // The program use fragments of code from using CppAD::AD; // =========================================
}; // ====================================
} void MPC::LoadParams(const std::map<string, double> ¶ms)
} vector MPC::Solve(Eigen::VectorXd state, Eigen::VectorXd coeffs)
} |
Beta Was this translation helpful? Give feedback.
-
It looks like there could be a bug in Mpc, your code, ipopt, or CppAD. CppAD does a lot of error checking (when NDEBUG is not defined) and is detecting the problem. I am not familiar with Mpc. I suggest you try valgrind and see if it detects the problem. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply, but I still don't know what the problem is. When I set options += "Integer print_level 0\n"; When the 0 in the code is changed to 5, the result is available, but when it is changed to 1 or 0, the program reports an error. |
Beta Was this translation helpful? Give feedback.
-
Did you try running the program using valgrind ? You could try to simplify your program. A simpler program that has the same error makes it easier to find. Perhaps you will find a very small change that makes the error go away. This may give you a clue as to where the error is. |
Beta Was this translation helpful? Give feedback.
-
Is this still a problem for you ? |
Beta Was this translation helpful? Give feedback.
-
When I do the cppad and ipopt joint solution, I run into some problems. The code is as follows.
#include
#include <cppad/ipopt/solve.hpp>
using namespace std;
namespace {
using CppAD::AD;
class FG_eval {
public:
typedef CPPAD_TESTVECTOR(AD) ADvector;
void operator()(ADvector& fg, const ADvector& x)
{
assert(fg.size() == 3);
assert(x.size() == 4);
// variables
AD x1 = x[0];
AD x2 = x[1];
AD x3 = x[2];
AD x4 = x[3];
// f(x) objective function
fg[0] = x1 * x4 * (x1 + x2 + x3) + x3;
// constraints
fg[1] = x1 * x2 * x3 * x4;
fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4;
return;
}
};
}
bool get_started(void)
{
bool ok = true;
size_t i;
typedef CPPAD_TESTVECTOR(double) Dvector;
}
int main()
![d492f1afcee8a9c97f1c3ffbcc82d16](https://user-images.githubusercontent.com/96851901/230318684-6bec03e7-18ca-4206-b9d3-7bd4bbf55a6b.jpg)
{
cout << "CppAD : Hello World Demo!" << endl;
get_started();
return 0;
}
The results are as follows:
Beta Was this translation helpful? Give feedback.
All reactions