Multivariate piecewise
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
No source file or test is named. Start by locating the current piecewise functionality and its breakpoint and decision-variable interface, then compare it with Pyomo's piecewise_nd and the linked forum example. Done should mean supporting multivariate inputs with multidimensional breakpoints and an additional decision variable for the output.
Written by the indexing model from the issue text.
Description
I don't think the current piecewise functionality supports multivariate piecewise (f(x, y)), as described in e.g., this paper.
Pyomo handles this by requesting the user to first discretise the domain using Delaunay triangulation (see here) and then to provide the y values at each of those mesh points. An example implementation is in this forum post:
import pyomo.environ as pyo
import pyomo.kernel as pmo
import numpy as np
from pyomo.core.kernel.piecewise_library.transforms_nd import piecewise_nd
model = pmo.block()
model.x = pmo.variable(lb=0, ub=3)
model.y = pmo.variable(lb=0, ub=3)
model.z = pmo.variable()
def f(x, y):
return x*y**2 + 20*np.sin(x*y)
var_list = [model.x, model.y]
tri = pmo.piecewise_util.generate_delaunay(var_list, num=20)
values = f(*tri.points.T)
model.pw = piecewise_nd(tri, values, input=var_list, output=model.z)
model.obj = pmo.objective(expr=model.z)
pyo.SolverFactory('glpk').solve(model, tee=True)
Implementation
Assuming we limit this to a 3D space, this would require the piecewise functionality to accept an additional set of breakpoints and an additional decision variable, and the y_breakpoints to be 2D.
You could have x_points and x1_points (or z_points?).
Why
An example of when this would be useful is for operating costs in an energy system model, where you want to be able to define a cost as a function of load rate (dispatch / nominal capacity) whilst nominal capacity is a decision variable. So, you would have load rate as x, nominal capacity as z, and operating cost as y.
- Dominant language
- Python
- Stars
- 257
- Forks
- 87
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 32
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyPSA/linopy
-
bug solver interface
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
documentation sparse
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
enhancement sparse
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Make the sparse path observable and controllable (.is_sparse, densify warning, per-call sparse=) Openenhancement sparse
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
enhancement performance sparse
Difficulty 4/5 3-5 days Newbie friendliness 68/100
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·