Skip to content

Commit 15041af

Browse files
authored
1 parent 4791512 commit 15041af

File tree

3 files changed

+98
-27
lines changed

3 files changed

+98
-27
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
99
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1010

1111
[compat]
12-
HiGHS_jll = "=1.7.1, =1.7.2, =1.8.0, =1.8.1, =1.9.0, =1.10.0"
12+
HiGHS_jll = "=1.11.0"
1313
MathOptInterface = "1.34"
1414
PrecompileTools = "1"
1515
SparseArrays = "1.6"

src/MOI_wrapper.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,9 +3207,11 @@ function CallbackFunction()
32073207
])
32083208
end
32093209

3210-
# HiGHS v1.10 introduced the user_solution field. For backwards compatibility,
3211-
# we default it to C_NULL.
3212-
HighsCallbackDataIn(terminate) = HighsCallbackDataIn(terminate, C_NULL)
3210+
# HiGHS v1.10 and HiGHS v1.11 introduced additional fields. We maintain this for
3211+
# backwards compatibility.
3212+
function HighsCallbackDataIn(terminate)
3213+
return HighsCallbackDataIn(terminate, C_NULL, C_NULL, 0, zero(HighsInt))
3214+
end
32133215

32143216
function _cfn_user_callback(
32153217
callback_type::Cint,

src/gen/libhighs.jl

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const HighsInt = Cint
1414
Struct to handle callback output data
1515
"""
1616
struct HighsCallbackDataOut
17+
cbdata::Ptr{Cvoid}
1718
log_type::Cint
1819
running_time::Cdouble
1920
simplex_iteration_count::HighsInt
@@ -26,6 +27,7 @@ struct HighsCallbackDataOut
2627
mip_dual_bound::Cdouble
2728
mip_gap::Cdouble
2829
mip_solution::Ptr{Cdouble}
30+
mip_solution_size::HighsInt
2931
cutpool_num_col::HighsInt
3032
cutpool_num_cut::HighsInt
3133
cutpool_num_nz::HighsInt
@@ -40,6 +42,9 @@ end
4042
struct HighsCallbackDataIn
4143
user_interrupt::Cint
4244
user_solution::Ptr{Cdouble}
45+
cbdata::Ptr{Cvoid}
46+
user_has_solution::Cint
47+
user_solution_size::HighsInt
4348
end
4449

4550
# typedef void ( * HighsCCallbackType ) ( int , const char * , const HighsCallbackDataOut * , HighsCallbackDataIn * , void * )
@@ -707,7 +712,7 @@ Get the type expected by an option.
707712
### Parameters
708713
* `highs`: A pointer to the Highs instance.
709714
* `option`: The name of the option.
710-
* `type`: An int in which the corresponding `kHighsOptionType` constant should be placed.
715+
* `type`: A [`HighsInt`](@ref) in which the corresponding `kHighsOptionType` constant should be placed.
711716
### Returns
712717
A `kHighsStatus` constant indicating whether the call succeeded.
713718
"""
@@ -808,7 +813,7 @@ end
808813
"""
809814
Highs_getIntOptionValues(highs, option, current_value, min_value, max_value, default_value)
810815
811-
Get the current and default values of an int option
816+
Get the current and default values of a [`HighsInt`](@ref) option
812817
813818
### Parameters
814819
* `highs`: A pointer to the Highs instance.
@@ -913,7 +918,7 @@ Get the type expected by an info item.
913918
### Parameters
914919
* `highs`: A pointer to the Highs instance.
915920
* `info`: The name of the info item.
916-
* `type`: An int in which the corresponding `kHighsOptionType` constant is stored.
921+
* `type`: A [`HighsInt`](@ref) in which the corresponding `kHighsOptionType` constant is stored.
917922
### Returns
918923
A `kHighsStatus` constant indicating whether the call succeeded.
919924
"""
@@ -976,7 +981,7 @@ Indicates whether a dual ray that is a certificate of primal infeasibility curre
976981
977982
### Parameters
978983
* `highs`: A pointer to the Highs instance.
979-
* `has_dual_ray`: A pointer to an int to store 1 if a dual ray currently exists.
984+
* `has_dual_ray`: A pointer to a [`HighsInt`](@ref) to store 1 if a dual ray currently exists.
980985
* `dual_ray_value`: An array of length [num\\_row] filled with the unbounded ray.
981986
### Returns
982987
A `kHighsStatus` constant indicating whether the call succeeded.
@@ -992,7 +997,7 @@ Indicates whether a dual unboundedness direction (corresponding to a certificate
992997
993998
### Parameters
994999
* `highs`: A pointer to the Highs instance.
995-
* `has_dual_unboundedness_direction`: A pointer to an int to store 1 if the dual unboundedness direction exists.
1000+
* `has_dual_unboundedness_direction`: A pointer to a [`HighsInt`](@ref) to store 1 if the dual unboundedness direction exists.
9961001
* `dual_unboundedness_direction_value`: An array of length [num\\_col] filled with the unboundedness direction.
9971002
"""
9981003
function Highs_getDualUnboundednessDirection(highs, has_dual_unboundedness_direction, dual_unboundedness_direction_value)
@@ -1006,7 +1011,7 @@ Indicates whether a primal ray that is a certificate of primal unboundedness cur
10061011
10071012
### Parameters
10081013
* `highs`: A pointer to the Highs instance.
1009-
* `has_primal_ray`: A pointer to an int to store 1 if the primal ray exists.
1014+
* `has_primal_ray`: A pointer to a [`HighsInt`](@ref) to store 1 if the primal ray exists.
10101015
* `primal_ray_value`: An array of length [num\\_col] filled with the unbounded ray.
10111016
### Returns
10121017
A `kHighsStatus` constant indicating whether the call succeeded.
@@ -1145,14 +1150,14 @@ Compute a row of ``B^{-1}A``.
11451150
11461151
See [`Highs_getBasicVariables`](@ref) for a description of the ``B`` matrix.
11471152
1148-
The arrays `row_vector` and `row_index` must have an allocated length of [num\\_row]. However, check `row_num_nz` to see how many non-zero elements are actually stored.
1153+
The arrays `row_vector` and `row_index` must have an allocated length of [num\\_col]. However, check `row_num_nz` to see how many non-zero elements are actually stored.
11491154
11501155
### Parameters
11511156
* `highs`: A pointer to the Highs instance.
11521157
* `row`: The index of the row to compute.
1153-
* `row_vector`: An array of length [num\\_row] in which to store the values of the non-zero elements.
1158+
* `row_vector`: An array of length [num\\_col] in which to store the values of the non-zero elements.
11541159
* `row_num_nz`: The number of non-zeros in the row.
1155-
* `row_index`: An array of length [num\\_row] in which to store the indices of the non-zero elements.
1160+
* `row_index`: An array of length [num\\_col] in which to store the indices of the non-zero elements.
11561161
### Returns
11571162
A `kHighsStatus` constant indicating whether the call succeeded.
11581163
"""
@@ -1277,7 +1282,7 @@ Start callback of given type
12771282
A `kHighsStatus` constant indicating whether the call succeeded.
12781283
"""
12791284
function Highs_startCallback(highs, callback_type)
1280-
ccall((:Highs_startCallback, libhighs), HighsInt, (Ptr{Cvoid}, Cint), highs, callback_type)
1285+
ccall((:Highs_startCallback, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt), highs, callback_type)
12811286
end
12821287

12831288
"""
@@ -1292,7 +1297,7 @@ Stop callback of given type
12921297
A `kHighsStatus` constant indicating whether the call succeeded.
12931298
"""
12941299
function Highs_stopCallback(highs, callback_type)
1295-
ccall((:Highs_stopCallback, libhighs), HighsInt, (Ptr{Cvoid}, Cint), highs, callback_type)
1300+
ccall((:Highs_stopCallback, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt), highs, callback_type)
12961301
end
12971302

12981303
"""
@@ -1733,6 +1738,24 @@ function Highs_changeRowBounds(highs, row, lower, upper)
17331738
ccall((:Highs_changeRowBounds, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt, Cdouble, Cdouble), highs, row, lower, upper)
17341739
end
17351740

1741+
"""
1742+
Highs_changeRowsBoundsByRange(highs, from_row, to_row, lower, upper)
1743+
1744+
Change the variable bounds of multiple adjacent rows.
1745+
1746+
### Parameters
1747+
* `highs`: A pointer to the Highs instance.
1748+
* `from_row`: The index of the first row whose bound changes.
1749+
* `to_row`: The index of the last row whose bound changes.
1750+
* `lower`: An array of length [to\\_row - from\\_row + 1] with the new lower bounds.
1751+
* `upper`: An array of length [to\\_row - from\\_row + 1] with the new upper bounds.
1752+
### Returns
1753+
A `kHighsStatus` constant indicating whether the call succeeded.
1754+
"""
1755+
function Highs_changeRowsBoundsByRange(highs, from_row, to_row, lower, upper)
1756+
ccall((:Highs_changeRowsBoundsByRange, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt, HighsInt, Ptr{Cdouble}, Ptr{Cdouble}), highs, from_row, to_row, lower, upper)
1757+
end
1758+
17361759
"""
17371760
Highs_changeRowsBoundsBySet(highs, num_set_entries, set, lower, upper)
17381761
@@ -1830,11 +1853,11 @@ Second, allocate new `matrix_index` and `matrix_value` arrays of length `num_nz`
18301853
* `highs`: A pointer to the Highs instance.
18311854
* `from_col`: The first column for which to query data for.
18321855
* `to_col`: The last column (inclusive) for which to query data for.
1833-
* `num_col`: An integer populated with the number of columns got from the model (this should equal `to\\_col - from\\_col + 1`).
1856+
* `num_col`: A [`HighsInt`](@ref) populated with the number of columns got from the model (this should equal `to\\_col - from\\_col + 1`).
18341857
* `costs`: An array of size [to\\_col - from\\_col + 1] for the column cost coefficients.
18351858
* `lower`: An array of size [to\\_col - from\\_col + 1] for the column lower bounds.
18361859
* `upper`: An array of size [to\\_col - from\\_col + 1] for the column upper bounds.
1837-
* `num_nz`: An integer to be populated with the number of non-zero elements in the constraint matrix.
1860+
* `num_nz`: A [`HighsInt`](@ref) to be populated with the number of non-zero elements in the constraint matrix.
18381861
* `matrix_start`: An array of size [to\\_col - from\\_col + 1] with the start indices of each column in `matrix_index` and `matrix_value`.
18391862
* `matrix_index`: An array of size [num\\_nz] with the row indices of each element in the constraint matrix.
18401863
* `matrix_value`: An array of size [num\\_nz] with the non-zero elements of the constraint matrix.
@@ -1893,10 +1916,10 @@ Second, allocate new `matrix_index` and `matrix_value` arrays of length `num_nz`
18931916
* `highs`: A pointer to the Highs instance.
18941917
* `from_row`: The first row for which to query data for.
18951918
* `to_row`: The last row (inclusive) for which to query data for.
1896-
* `num_row`: An integer to be populated with the number of rows got from the model.
1919+
* `num_row`: A [`HighsInt`](@ref) to be populated with the number of rows got from the model.
18971920
* `lower`: An array of size [to\\_row - from\\_row + 1] for the row lower bounds.
18981921
* `upper`: An array of size [to\\_row - from\\_row + 1] for the row upper bounds.
1899-
* `num_nz`: An integer to be populated with the number of non-zero elements in the constraint matrix.
1922+
* `num_nz`: A [`HighsInt`](@ref) to be populated with the number of non-zero elements in the constraint matrix.
19001923
* `matrix_start`: An array of size [to\\_row - from\\_row + 1] with the start indices of each row in `matrix_index` and `matrix_value`.
19011924
* `matrix_index`: An array of size [num\\_nz] with the column indices of each element in the constraint matrix.
19021925
* `matrix_value`: An array of size [num\\_nz] with the non-zero elements of the constraint matrix.
@@ -2011,7 +2034,7 @@ Get the integrality of a column.
20112034
20122035
### Parameters
20132036
* `col`: The index of the column to query.
2014-
* `integrality`: An integer in which the integrality of the column should be placed. The integer is one of the `kHighsVarTypeXXX` constants.
2037+
* `integrality`: A [`HighsInt`](@ref) in which the integrality of the column should be placed. The integer is one of the `kHighsVarTypeXXX` constants.
20152038
### Returns
20162039
A `kHighsStatus` constant indicating whether the call succeeded.
20172040
"""
@@ -2079,7 +2102,7 @@ Delete multiple adjacent rows.
20792102
A `kHighsStatus` constant indicating whether the call succeeded.
20802103
"""
20812104
function Highs_deleteRowsByRange(highs, from_row, to_row)
2082-
ccall((:Highs_deleteRowsByRange, libhighs), HighsInt, (Ptr{Cvoid}, Cint, HighsInt), highs, from_row, to_row)
2105+
ccall((:Highs_deleteRowsByRange, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt, HighsInt), highs, from_row, to_row)
20832106
end
20842107

20852108
"""
@@ -2337,7 +2360,7 @@ Set a primal (and possibly dual) solution as a starting point, then run crossove
23372360
A `kHighsStatus` constant indicating whether the call succeeded.
23382361
"""
23392362
function Highs_crossover(highs, num_col, num_row, col_value, col_dual, row_dual)
2340-
ccall((:Highs_crossover, libhighs), HighsInt, (Ptr{Cvoid}, Cint, Cint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), highs, num_col, num_row, col_value, col_dual, row_dual)
2363+
ccall((:Highs_crossover, libhighs), HighsInt, (Ptr{Cvoid}, HighsInt, HighsInt, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), highs, num_col, num_row, col_value, col_dual, row_dual)
23412364
end
23422365

23432366
"""
@@ -2437,6 +2460,55 @@ function Highs_getCallbackDataOutItem(data_out, item_name)
24372460
ccall((:Highs_getCallbackDataOutItem, libhighs), Ptr{Cvoid}, (Ptr{HighsCallbackDataOut}, Ptr{Cchar}), data_out, item_name)
24382461
end
24392462

2463+
"""
2464+
Highs_setCallbackSolution(data_in, num_entries, value)
2465+
2466+
Set a solution within a callback by passing a subset of the values.
2467+
2468+
For any values that are unavailable/unknown, pass kHighsUndefined.
2469+
2470+
### Parameters
2471+
* `data_in`: A pointer to the callback input data instance.
2472+
* `num_entries`: Number of variables in the set
2473+
* `value`: An array of length [num\\_entries <= num\\_col] with column solution values.
2474+
### Returns
2475+
A `kHighsStatus` constant indicating whether the call succeeded.
2476+
"""
2477+
function Highs_setCallbackSolution(data_in, num_entries, value)
2478+
ccall((:Highs_setCallbackSolution, libhighs), HighsInt, (Ptr{HighsCallbackDataIn}, HighsInt, Ptr{Cdouble}), data_in, num_entries, value)
2479+
end
2480+
2481+
"""
2482+
Highs_setCallbackSparseSolution(data_in, num_entries, index, value)
2483+
2484+
Set a partial primal solution by passing values for a set of variables, within a valid callback.
2485+
2486+
### Parameters
2487+
* `data_in`: A pointer to the callback input data instance.
2488+
* `num_entries`: Number of variables in the set
2489+
* `index`: Indices of variables in the set
2490+
* `value`: Values of variables in the set
2491+
### Returns
2492+
A `kHighsStatus` constant indicating whether the call succeeded.
2493+
"""
2494+
function Highs_setCallbackSparseSolution(data_in, num_entries, index, value)
2495+
ccall((:Highs_setCallbackSparseSolution, libhighs), HighsInt, (Ptr{HighsCallbackDataIn}, HighsInt, Ptr{HighsInt}, Ptr{Cdouble}), data_in, num_entries, index, value)
2496+
end
2497+
2498+
"""
2499+
Highs_repairCallbackSolution(data_in)
2500+
2501+
Finds a feasible solution for a given (partial) primal user solution, within a valid callback.
2502+
2503+
On success, the user solution is updated within the callback input data instance.
2504+
2505+
### Returns
2506+
A `kHighsStatus` constant indicating whether the call succeeded.
2507+
"""
2508+
function Highs_repairCallbackSolution(data_in)
2509+
ccall((:Highs_repairCallbackSolution, libhighs), HighsInt, (Ptr{HighsCallbackDataIn},), data_in)
2510+
end
2511+
24402512
"""
24412513
Highs_compilationDate()
24422514
@@ -2553,18 +2625,14 @@ const HighsUInt = Cuint
25532625

25542626
const CMAKE_BUILD_TYPE = "Release"
25552627

2556-
const CMAKE_INSTALL_PREFIX = "/workspace/destdir"
2557-
2558-
const HIGHS_GITHASH = "fd8665394e"
2628+
const HIGHS_GITHASH = "6eca8325a4"
25592629

25602630
const HIGHS_VERSION_MAJOR = 1
25612631

25622632
const HIGHS_VERSION_MINOR = 10
25632633

25642634
const HIGHS_VERSION_PATCH = 0
25652635

2566-
const HIGHS_DIR = "/workspace/srcdir/HiGHS"
2567-
25682636
const HIGHSINT_FORMAT = "d"
25692637

25702638
const kHighsMaximumStringLength = HighsInt(512)
@@ -2635,3 +2703,4 @@ const kHighsCallbackMipLogging = HighsInt(5)
26352703
const kHighsCallbackMipInterrupt = HighsInt(6)
26362704
const kHighsCallbackMipGetCutPool = HighsInt(7)
26372705
const kHighsCallbackMipDefineLazyConstraints = HighsInt(8)
2706+
const kHighsCallbackCallbackMipUserSolution = HighsInt(9)

0 commit comments

Comments
 (0)