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

Constraint with more than one variable #10

Open
alexBoal opened this issue Apr 8, 2022 · 1 comment
Open

Constraint with more than one variable #10

alexBoal opened this issue Apr 8, 2022 · 1 comment

Comments

@alexBoal
Copy link

alexBoal commented Apr 8, 2022

Hi,

I have a question...is it possible to define a constraint with more than one variable?
As an e.g.:
Our input vector is x= {-1, 1}.
We have some bounds like: 0 < x < 5 and y >= 0.
Is it possible to define a constraint like y - x^2 >= 0? If yes, how is it done if in input we only has x? Should we have as input x and y?

Thanks ;)

@jamesasefa
Copy link
Collaborator

Hi @alexBoal yes this is possible, see the example in https://github.com/j-asefa/slsqp4j/blob/master/slsqp4j/src/test/java/com/skew/slsqp4j/TestUtil.java#L125

You'd want something like:

    public static final class YourFunc implements Vector2VectorFunc
    {
        @Override
        public double[] apply(double[] x, double... arg)
        {
            return new double[] {x[0], - (x[1] * x[1]) };
        }
    }

And define this as a VectorConstraint with constraintType = INEQ

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

2 participants