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

Open design questions #6

Open
odow opened this issue Mar 29, 2022 · 0 comments
Open

Open design questions #6

odow opened this issue Mar 29, 2022 · 0 comments

Comments

@odow
Copy link
Contributor

odow commented Mar 29, 2022

Here are some open design questions that aren't really bugs or features requests, but more things to think about. Resolving them will probably need changes to JuMP.

What happens if some coefficients are missing units?

using UnitJuMP
model = Model()
@variable(model, x >= 0, u"m/s")
@variable(model, x >= 0, u"m/s")
@constraint(model, x <= 1)                  # Option 1
@constraint(model, x <= 1u"m/s")            # Option 2
@constraint(model, x <= 1, u"ft/s")         # Option 3
@constraint(model, x <= 1u"m/s", u"ft/s")   # Option 4

Currently, only options 2 and 4 are supported. That seems like the right answer. We should favor strictness.

How to handle units in expressions and the objective?

JuMP allows tagging and extending variables and constraints, but not expressions and the objective function:

using UnitJuMP
model = Model()
@variable(model, x >= 0, u"m/s")
expr = @expression(model, x + 1u"m/s")
@objective(model, Min, expr)
# Potential syntax
expr = @expression(model, x + 1u"m/s", u"f/s")
@objective(model, Min, expr, u"f/s")

objective_value ignores units

I don't know what we could do about this:

julia> using UnitJuMP, HiGHS

julia> model = Model(HiGHS.Optimizer);

julia> @variable(model, x >= 1.2, u"m/s")
x m s⁻¹

julia> obj = @objective(model, Min, 2 * x + 1u"m/s")
2 x + 1 [m s⁻¹]

julia> optimize!(model)
Presolving model
0 rows, 0 cols, 0 nonzeros
0 rows, 0 cols, 0 nonzeros
Presolve : Reductions: rows 0(-0); columns 0(-1); elements 0(-0) - Reduced to empty
Solving the original LP from the solution after postsolve
Solving an unconstrained LP with 1 columns
Model   status      : Optimal
Objective value     :  3.4000000000e+00
HiGHS run time      :          0.00

julia> objective_value(model)
3.4

julia> value(obj)
3.4 m s⁻¹
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