-
Notifications
You must be signed in to change notification settings - Fork 99
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
ipopt and cppad tests #174
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. |
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. |
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. |
Error from an unknown source means that there is an unknown problem on your system. Try running your program using valgrind; |
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. |
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)
} |
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. |
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. |
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. |
Is this still a problem for you ? |
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()
{
cout << "CppAD : Hello World Demo!" << endl;
get_started();
return 0;
}
The results are as follows:
The text was updated successfully, but these errors were encountered: