# Starting with HiGHS

I have been messing about with HiGHS and trying to get a hang of its capability.

Here is an example of a simple model from their github repo https://github.com/ERGO-Code/HiGHS/blob/master/examples/call_highs_from_python.py

In this example, adding variables and constraints is done through lp.col and lp.row respectively.

I'm getting a handle on how to do that, but here is another example from the repo https://github.com/ERGO-Code/HiGHS/blob/master/examples/minimal.py#L8

where they use addVar and addConstr instead. This of course simpler and more straightforward. Anyway, when I try to replicate that addVar works and all the variables are added. On the other hand, addConstr results in an attribute error AttributeError: 'Highs' object has no attribute 'addConstr'

I have been looking at the documentation with no luck to fix this issue. I have the latest version of the library. I'm wondering if this is something they haven't released yet maybe? I tried also to find the source code to see what function and attribute the model object has but couldn't find that either.

With version 1.5.3 you should add constraints using the addRow(...) method in the format lhs <= constraint <= rhs

m = highspy.Highs()
lhs,
rhs,
quantity of non-zero variables
indexes of variables
coefficients of the variables
)


For instance, if you have a knapscack constraint like $$\sum_{i} w_{i} * x_{ij} <= c * y_{j}, \forall j$$, then the code should be:

m = highspy.Highs()
for j in B:
-highspy.kHighsInf,
0,
N+1,
[idx_x[i,j] for i in range(N)]+[idx_y[j]],
[w[i] for i in range(N)]+[-c]
)


The latest release @ github is 1.6.0

The latest release available @ pypi is 1.5.3. This is the one you obtain when installing through pip install highspy.

While the feature you are trying to use was added (to some branch; see MR) in April 2023 and 1.5.3 was released in May 2023, it seems it's NOT part of 1.5.3 as indicated in this git-compare of the two releases

Well... at least it looks like it. Imho the git-history/branching looks kind of "wild". Your observation of having access to one function but not the other is strange but i think it's a result of some overload (which looks a bit scary).