Skip to content
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

How to specify a problem with no constraints? #2

Open
daviddoria opened this issue Jun 6, 2013 · 1 comment
Open

How to specify a problem with no constraints? #2

daviddoria opened this issue Jun 6, 2013 · 1 comment

Comments

@daviddoria
Copy link

I tried to specify a very simple program (here it is actually not even specified, the containers are just setup) that has no constraints. You can see that I tried to make the constraint matrices have zero rows:
Eigen::MatrixXd Ci(n,0);

and the constraint vectors have zero length:

int zero = 0;
Eigen::VectorXd ce(zero);

Here is the code, but when I run it I get:

QPDemo: /home/doriad/src/QP/eigen/Eigen/src/Core/Matrix.h:235: Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Index) [with _Scalar = double; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1; Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Index = long int]: Assertion `dim > 0' failed.

Can you please let me know how to specify a problem with no constraints?

include

include "uQuadProg++.hh"

include <Eigen/Eigen>

include <EigenQP.h>

int main (int argc, char *const argv[])
{
int n = 2;
Eigen::MatrixXd G(n,n);
Eigen::MatrixXd Ci(n,0);
Eigen::MatrixXd Ce(n,0);

Eigen::VectorXd g0(n);
int zero = 0;
Eigen::VectorXd ce(zero);
Eigen::VectorXd ci(zero);
Eigen::VectorXd x(n);

double objectiveValue = QP::solve_quadprog(G, g0, Ce, ce, Ci, ci, x);
std::cout << "objectiveValue: " << objectiveValue << std::endl;
std::cout <<"Solution:" << std::endl << x << std::endl;

}

@ghost
Copy link

ghost commented Aug 30, 2013

Well, if you do not have any constraints, you can just calculate your x=(P+P^T)^(-1)*c
However, it also works when you pass empty patrices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant