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

Cannot solve simplest 2-dimensional example #121

Open
Daniel-Alievsky opened this issue May 27, 2022 · 1 comment
Open

Cannot solve simplest 2-dimensional example #121

Daniel-Alievsky opened this issue May 27, 2022 · 1 comment

Comments

@Daniel-Alievsky
Copy link

Can you consult me, I didn't understand this from your documentation.
Usually, the common task of linear programming is like the following (2-dimensional example):
v1 = a1x + b1y
v2 = a2x + b2y
goal = ax + by
min1 <= v1 <= max1
min2 <= v2 <= max2
I need to maximize "goal".
What JSON I need to create to describe this task?

For example, I tried to resolve the simplest task.
-1 <= x + y <= 1
-1 <= -x + y <= 1
(rhomb)
I want to maximize "x". Result should be x=1, y=0.

I entered the JSON:

{
    "optimize": "x",
    "opType": "max",
    "constraints": {
        "v1": {"min": -1, "max":  1},
        "v2": {"min": -1, "max":  1}
    },
    "variables": {
        "x": {
            "v1": 1,
            "v2": 1
        },
        "y": {
            "v1": 1,
            "v2": -1
        }
    }
}

I expected to see: x=1, y=0, result=1. Instead of this, your solver returns:

{
	"feasible": true,
	"result": 0,
	"bounded": true
}

What does it mean??

Also, how can I specify that I want to maximize some linear combination of x, y, for example, 3.2x+1.4y? Should I do the following?

{
    "optimize": "g",
    "opType": "max",
    "constraints": {
        "v1": {"min": -1, "max":  1},
        "v2": {"min": -1, "max":  1}
    },
    "variables": {
        "x": {
            "v1": 1,
            "v2": 1,
            "g": 3.2
        },
        "y": {
            "v1": 1,
            "v2": -1,
            "g": 1.4
        }
    }
}

Thank you!

@reidev275
Copy link

@Daniel-Alievsky your final question regarding 3.2x + 1.4y has a correct example. Given a max occurrence of 1 for both v1 and v2 the best option is to do 1 x which provides a g value of 3.2.

{ feasible: true, result: 3.2, bounded: true, x: 1 }

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