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

Constraints as expressions using variable attributes? #108

Open
Ramenhotep opened this issue Mar 18, 2020 · 3 comments
Open

Constraints as expressions using variable attributes? #108

Ramenhotep opened this issue Mar 18, 2020 · 3 comments

Comments

@Ramenhotep
Copy link

This is working great for simple problems, but is there no way to build constraints as expressions using variable attributes, like:

constraints": {
            "wood": {"max": "storage"},
            "labor" + "storage": {"max": 110},
  },
@diligence-dev
Copy link

Would also be interested in this. https://github.com/njoubert/csp.js seems to support this with functions, but it does not run in the browser.

@diligence-dev
Copy link

I found a workaround:

  • "wood": {"max": "storage"}, means wood <= storage or wood - storage <= 0
  • add a new constraint "wood - storage": {"max": "0"},
  • change the variables: "wood": {"wood - storage": 1} and "storage": {"wood - storage": -1}
    Same thing can be done for the other constraint, add "labor + storage": 1 to the labor and the storage variable.

@apolinario
Copy link

apolinario commented Dec 17, 2020

I have the same issue. I have this lp file format array:

var model = [
          "max: x00 + x01 + x10 + x11",
          "x10 + x11 = 1.00 x00 + 1.00 x01 + 1.00 x10 + 1.00 x11",
          "x01 + x11 = 0.15 x00 + 0.15 x01 + 0.15 x10 + 0.15 x11",
          "x01 + x00 = 0.00 x00 + 0.00 x01 + 0.00 x10 + 0.00 x11",
          "x10 + x00 = 0.85 x00 + 0.85 x01 + 0.85 x10 + 0.85 x11",
          "x00 <= 60",
          "x01 <= 30",
          "x10 <= 100",
          "x11 <= 50",
];

And can't get it to work on jsLPSolver. If I use the solver.ReformatLP() function, I believe it is a bug because it thinks my value is 11 (probably because of this last variable x11). I also tried scaling everything up by multiplying by 100 without results

I also didn't find a way to natively create this array from scratch

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

3 participants