Open
Description
Version Checks (indicate both or one)
-
I have confirmed this bug exists on the lastest release of Linopy.
-
I have confirmed this bug exists on the current
master
branch of Linopy.
Issue Description
If you try to use CBC solver without highspy installed you get a vague "NameError"
If you try to pass a variable to add_objective, it gets caught by the type checker
Reproducible Example
# Example 1
import linopy
model = linopy.Model()
x = model.add_variables(name="x", lower=0.0)
model.add_constraints(x >= 0.0)
model.add_objective(x*1.0, sense="min")
model.solve(solver_name="cbc") # NameError: name 'highspy' is not defined
# Example 2
import linopy
model = linopy.Model()
x = model.add_variables(name="x", lower=0.0)
model.add_constraints(x >= 0.0)
model.add_objective(x, sense="min") # ValueError: Invalid type of `expr`
Expected Behavior
I expect to get a useful message to say that highspy should be installed to use cbc
I expect to be able to pass a Variable to the add_objective message
Installed Versions
Bottleneck==1.4.2
click==8.1.8
cloudpickle==3.1.1
colorama==0.4.6
dask==2025.4.1
deprecation==2.1.0
fsspec==2025.3.2
linopy==0.5.3
locket==1.0.0
numexpr==2.10.2
numpy==2.2.5
packaging==25.0
pandas==2.2.3
partd==1.4.2
polars==1.29.0
PuLP==3.1.1
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
scipy==1.15.2
six==1.17.0
toolz==1.0.0
tqdm==4.67.1
tzdata==2025.2
xarray==2025.4.0