-
Notifications
You must be signed in to change notification settings - Fork 183
/
highs_c_api.h
2374 lines (2190 loc) · 97.5 KB
/
highs_c_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* This file is part of the HiGHS linear optimization suite */
/* */
/* Written and engineered 2008-2024 by Julian Hall, Ivet Galabova, */
/* Leona Gottwald and Michael Feldmeier */
/* */
/* Available as open-source under the MIT License */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef HIGHS_C_API
#define HIGHS_C_API
//
// Welcome to the HiGHS C API!
//
// The simplest way to use HiGHS to solve an LP, MIP or QP from C is
// to pass the problem data to the appropriate method Highs_lpCall,
// Highs_mipCall or Highs_qpCall, and these methods return the
// appropriate solution information
//
// For sophisticated applications, where esoteric solution
// information is needed, or if a sequence of modified models need to
// be solved, use the Highs_create method to generate a pointer to an
// instance of the C++ Highs class, and then use any of a large number
// of models for which this pointer is the first parameter.
//
#include "lp_data/HighsCallbackStruct.h"
const HighsInt kHighsMaximumStringLength = 512;
const HighsInt kHighsStatusError = -1;
const HighsInt kHighsStatusOk = 0;
const HighsInt kHighsStatusWarning = 1;
const HighsInt kHighsVarTypeContinuous = 0;
const HighsInt kHighsVarTypeInteger = 1;
const HighsInt kHighsVarTypeSemiContinuous = 2;
const HighsInt kHighsVarTypeSemiInteger = 3;
const HighsInt kHighsVarTypeImplicitInteger = 4;
const HighsInt kHighsOptionTypeBool = 0;
const HighsInt kHighsOptionTypeInt = 1;
const HighsInt kHighsOptionTypeDouble = 2;
const HighsInt kHighsOptionTypeString = 3;
const HighsInt kHighsInfoTypeInt64 = -1;
const HighsInt kHighsInfoTypeInt = 1;
const HighsInt kHighsInfoTypeDouble = 2;
const HighsInt kHighsObjSenseMinimize = 1;
const HighsInt kHighsObjSenseMaximize = -1;
const HighsInt kHighsMatrixFormatColwise = 1;
const HighsInt kHighsMatrixFormatRowwise = 2;
const HighsInt kHighsHessianFormatTriangular = 1;
const HighsInt kHighsHessianFormatSquare = 2;
const HighsInt kHighsSolutionStatusNone = 0;
const HighsInt kHighsSolutionStatusInfeasible = 1;
const HighsInt kHighsSolutionStatusFeasible = 2;
const HighsInt kHighsBasisValidityInvalid = 0;
const HighsInt kHighsBasisValidityValid = 1;
const HighsInt kHighsPresolveStatusNotPresolved = -1;
const HighsInt kHighsPresolveStatusNotReduced = 0;
const HighsInt kHighsPresolveStatusInfeasible = 1;
const HighsInt kHighsPresolveStatusUnboundedOrInfeasible = 2;
const HighsInt kHighsPresolveStatusReduced = 3;
const HighsInt kHighsPresolveStatusReducedToEmpty = 4;
const HighsInt kHighsPresolveStatusTimeout = 5;
const HighsInt kHighsPresolveStatusNullError = 6;
const HighsInt kHighsPresolveStatusOptionsError = 7;
const HighsInt kHighsPresolveStatusOutOfMemory = 8;
const HighsInt kHighsModelStatusNotset = 0;
const HighsInt kHighsModelStatusLoadError = 1;
const HighsInt kHighsModelStatusModelError = 2;
const HighsInt kHighsModelStatusPresolveError = 3;
const HighsInt kHighsModelStatusSolveError = 4;
const HighsInt kHighsModelStatusPostsolveError = 5;
const HighsInt kHighsModelStatusModelEmpty = 6;
const HighsInt kHighsModelStatusOptimal = 7;
const HighsInt kHighsModelStatusInfeasible = 8;
const HighsInt kHighsModelStatusUnboundedOrInfeasible = 9;
const HighsInt kHighsModelStatusUnbounded = 10;
const HighsInt kHighsModelStatusObjectiveBound = 11;
const HighsInt kHighsModelStatusObjectiveTarget = 12;
const HighsInt kHighsModelStatusTimeLimit = 13;
const HighsInt kHighsModelStatusIterationLimit = 14;
const HighsInt kHighsModelStatusUnknown = 15;
const HighsInt kHighsModelStatusSolutionLimit = 16;
const HighsInt kHighsModelStatusInterrupt = 17;
const HighsInt kHighsBasisStatusLower = 0;
const HighsInt kHighsBasisStatusBasic = 1;
const HighsInt kHighsBasisStatusUpper = 2;
const HighsInt kHighsBasisStatusZero = 3;
const HighsInt kHighsBasisStatusNonbasic = 4;
const HighsInt kHighsCallbackLogging = 0;
const HighsInt kHighsCallbackSimplexInterrupt = 1;
const HighsInt kHighsCallbackIpmInterrupt = 2;
const HighsInt kHighsCallbackMipSolution = 3;
const HighsInt kHighsCallbackMipImprovingSolution = 4;
const HighsInt kHighsCallbackMipLogging = 5;
const HighsInt kHighsCallbackMipInterrupt = 6;
const HighsInt kHighsCallbackMipGetCutPool = 7;
const HighsInt kHighsCallbackMipDefineLazyConstraints = 8;
const char* const kHighsCallbackDataOutLogTypeName = "log_type";
const char* const kHighsCallbackDataOutRunningTimeName = "running_time";
const char* const kHighsCallbackDataOutSimplexIterationCountName =
"simplex_iteration_count";
const char* const kHighsCallbackDataOutIpmIterationCountName =
"ipm_iteration_count";
const char* const kHighsCallbackDataOutPdlpIterationCountName =
"pdlp_iteration_count";
const char* const kHighsCallbackDataOutObjectiveFunctionValueName =
"objective_function_value";
const char* const kHighsCallbackDataOutMipNodeCountName = "mip_node_count";
const char* const kHighsCallbackDataOutMipTotalLpIterationsName =
"mip_total_lp_iterations";
const char* const kHighsCallbackDataOutMipPrimalBoundName = "mip_primal_bound";
const char* const kHighsCallbackDataOutMipDualBoundName = "mip_dual_bound";
const char* const kHighsCallbackDataOutMipGapName = "mip_gap";
const char* const kHighsCallbackDataOutMipSolutionName = "mip_solution";
const char* const kHighsCallbackDataOutCutpoolNumColName = "cutpool_num_col";
const char* const kHighsCallbackDataOutCutpoolNumCutName = "cutpool_num_cut";
const char* const kHighsCallbackDataOutCutpoolNumNzName = "cutpool_num_nz";
const char* const kHighsCallbackDataOutCutpoolStartName = "cutpool_start";
const char* const kHighsCallbackDataOutCutpoolIndexName = "cutpool_index";
const char* const kHighsCallbackDataOutCutpoolValueName = "cutpool_value";
const char* const kHighsCallbackDataOutCutpoolLowerName = "cutpool_lower";
const char* const kHighsCallbackDataOutCutpoolUpperName = "cutpool_upper";
#ifdef __cplusplus
extern "C" {
#endif
/**
* Formulate and solve a linear program using HiGHS.
*
* @param num_col The number of columns.
* @param num_row The number of rows.
* @param num_nz The number of nonzeros in the constraint matrix.
* @param a_format The format of the constraint matrix as a
* `kHighsMatrixFormat` constant.
* @param sense The optimization sense as a `kHighsObjSense` constant.
* @param offset The objective constant.
* @param col_cost An array of length [num_col] with the column costs.
* @param col_lower An array of length [num_col] with the column lower bounds.
* @param col_upper An array of length [num_col] with the column upper bounds.
* @param row_lower An array of length [num_row] with the row lower bounds.
* @param row_upper An array of length [num_row] with the row upper bounds.
* @param a_start The constraint matrix is provided to HiGHS in compressed
* sparse column form (if `a_format` is
* `kHighsMatrixFormatColwise`, otherwise compressed sparse row
* form). The sparse matrix consists of three arrays,
* `a_start`, `a_index`, and `a_value`. `a_start` is an array
* of length [num_col] containing the starting index of each
* column in `a_index`. If `a_format` is
* `kHighsMatrixFormatRowwise` the array is of length [num_row]
* corresponding to each row.
* @param a_index An array of length [num_nz] with indices of matrix entries.
* @param a_value An array of length [num_nz] with values of matrix entries.
*
* @param col_value An array of length [num_col], to be filled with the
* primal column solution.
* @param col_dual An array of length [num_col], to be filled with the
* dual column solution.
* @param row_value An array of length [num_row], to be filled with the
* primal row solution.
* @param row_dual An array of length [num_row], to be filled with the
* dual row solution.
* @param col_basis_status An array of length [num_col], to be filled with the
* basis status of the columns in the form of a
* `kHighsBasisStatus` constant.
* @param row_basis_status An array of length [num_row], to be filled with the
* basis status of the rows in the form of a
* `kHighsBasisStatus` constant.
* @param model_status The location in which to place the termination
* status of the model after the solve in the form of a
* `kHighsModelStatus` constant.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_lpCall(const HighsInt num_col, const HighsInt num_row,
const HighsInt num_nz, const HighsInt a_format,
const HighsInt sense, const double offset,
const double* col_cost, const double* col_lower,
const double* col_upper, const double* row_lower,
const double* row_upper, const HighsInt* a_start,
const HighsInt* a_index, const double* a_value,
double* col_value, double* col_dual, double* row_value,
double* row_dual, HighsInt* col_basis_status,
HighsInt* row_basis_status, HighsInt* model_status);
/**
* Formulate and solve a mixed-integer linear program using HiGHS.
*
* The signature of this method is identical to `Highs_lpCall`, except that it
* has an additional `integrality` argument, and that it is missing the
* `col_dual`, `row_dual`, `col_basis_status` and `row_basis_status` arguments.
*
* @param integrality An array of length [num_col], containing a
* `kHighsVarType` constant for each column.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_mipCall(const HighsInt num_col, const HighsInt num_row,
const HighsInt num_nz, const HighsInt a_format,
const HighsInt sense, const double offset,
const double* col_cost, const double* col_lower,
const double* col_upper, const double* row_lower,
const double* row_upper, const HighsInt* a_start,
const HighsInt* a_index, const double* a_value,
const HighsInt* integrality, double* col_value,
double* row_value, HighsInt* model_status);
/**
* Formulate and solve a quadratic program using HiGHS.
*
* The signature of this method is identical to `Highs_lpCall`, except that it
* has additional arguments for specifying the Hessian matrix.
*
* @param q_num_nz The number of nonzeros in the Hessian matrix.
* @param q_format The format of the Hessian matrix in the form of a
* `kHighsHessianStatus` constant. If q_num_nz > 0, this must
* be `kHighsHessianFormatTriangular`.
* @param q_start The Hessian matrix is provided to HiGHS as the lower
* triangular component in compressed sparse column form
* (or, equivalently, as the upper triangular component
* in compressed sparse row form). The sparse matrix consists
* of three arrays, `q_start`, `q_index`, and `q_value`.
* `q_start` is an array of length [num_col].
* @param q_index An array of length [q_num_nz] with indices of matrix
* entries.
* @param q_value An array of length [q_num_nz] with values of matrix entries.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_qpCall(
const HighsInt num_col, const HighsInt num_row, const HighsInt num_nz,
const HighsInt q_num_nz, const HighsInt a_format, const HighsInt q_format,
const HighsInt sense, const double offset, const double* col_cost,
const double* col_lower, const double* col_upper, const double* row_lower,
const double* row_upper, const HighsInt* a_start, const HighsInt* a_index,
const double* a_value, const HighsInt* q_start, const HighsInt* q_index,
const double* q_value, double* col_value, double* col_dual,
double* row_value, double* row_dual, HighsInt* col_basis_status,
HighsInt* row_basis_status, HighsInt* model_status);
/**
* Create a Highs instance and return the reference.
*
* Call `Highs_destroy` on the returned reference to clean up allocated memory.
*
* @returns A pointer to the Highs instance.
*/
void* Highs_create(void);
/**
* Destroy the model `highs` created by `Highs_create` and free all
* corresponding memory. Future calls using `highs` are not allowed.
*
* To empty a model without invalidating `highs`, see `Highs_clearModel`.
*
* @param highs A pointer to the Highs instance.
*/
void Highs_destroy(void* highs);
/**
* Return the HiGHS version number as a string of the form "vX.Y.Z".
*
* @returns The HiGHS version as a `char*`.
*/
const char* Highs_version(void);
/**
* Return the HiGHS major version number.
*
* @returns The HiGHS major version number.
*/
HighsInt Highs_versionMajor(void);
/**
* Return the HiGHS minor version number.
*
* @returns The HiGHS minor version number.
*/
HighsInt Highs_versionMinor(void);
/**
* Return the HiGHS patch version number.
*
* @returns The HiGHS patch version number.
*/
HighsInt Highs_versionPatch(void);
/**
* Return the HiGHS githash.
*
* @returns The HiGHS githash.
*/
const char* Highs_githash(void);
/**
* Read a model from `filename` into `highs`.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename to read.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_readModel(void* highs, const char* filename);
/**
* Write the model in `highs` to `filename`.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename to write.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writeModel(void* highs, const char* filename);
/**
* Write the presolved model in `highs` to `filename`.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename to write.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writePresolvedModel(void* highs, const char* filename);
/**
* Reset the options and then call `clearModel`.
*
* See `Highs_destroy` to free all associated memory.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_clear(void* highs);
/**
* Remove all variables and constraints from the model `highs`, but do not
* invalidate the pointer `highs`. Future calls (for example, adding new
* variables and constraints) are allowed.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_clearModel(void* highs);
/**
* Clear all solution data associated with the model.
*
* See `Highs_destroy` to clear the model and free all associated memory.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_clearSolver(void* highs);
/**
* Presolve a model.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_presolve(void* highs);
/**
* Optimize a model. The algorithm used by HiGHS depends on the options that
* have been set.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_run(void* highs);
/**
* Postsolve a model using a primal (and possibly dual) solution.
*
* @param highs A pointer to the Highs instance.
* @param col_value An array of length [num_col] with the column solution
* values.
* @param col_dual An array of length [num_col] with the column dual
* values, or a null pointer if not known.
* @param row_dual An array of length [num_row] with the row dual values,
* or a null pointer if not known.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_postsolve(void* highs, const double* col_value,
const double* col_dual, const double* row_dual);
/**
* Write the solution information (including dual and basis status, if
* available) to a file.
*
* See also: `Highs_writeSolutionPretty`.
*
* @param highs A pointer to the Highs instance.
* @param filename The name of the file to write the results to.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writeSolution(const void* highs, const char* filename);
/**
* Write the solution information (including dual and basis status, if
* available) to a file in a human-readable format.
*
* The method identical to `Highs_writeSolution`, except that the
* printout is in a human-readable format.
*
* @param highs A pointer to the Highs instance.
* @param filename The name of the file to write the results to.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writeSolutionPretty(const void* highs, const char* filename);
/**
* Pass a linear program (LP) to HiGHS in a single function call.
*
* The signature of this function is identical to `Highs_passModel`, without the
* arguments for passing the Hessian matrix of a quadratic program and the
* integrality vector.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passLp(void* highs, const HighsInt num_col,
const HighsInt num_row, const HighsInt num_nz,
const HighsInt a_format, const HighsInt sense,
const double offset, const double* col_cost,
const double* col_lower, const double* col_upper,
const double* row_lower, const double* row_upper,
const HighsInt* a_start, const HighsInt* a_index,
const double* a_value);
/**
* Pass a mixed-integer linear program (MILP) to HiGHS in a single function
* call.
*
* The signature of function is identical to `Highs_passModel`, without the
* arguments for passing the Hessian matrix of a quadratic program.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passMip(void* highs, const HighsInt num_col,
const HighsInt num_row, const HighsInt num_nz,
const HighsInt a_format, const HighsInt sense,
const double offset, const double* col_cost,
const double* col_lower, const double* col_upper,
const double* row_lower, const double* row_upper,
const HighsInt* a_start, const HighsInt* a_index,
const double* a_value, const HighsInt* integrality);
/**
* Pass a model to HiGHS in a single function call. This is faster than
* constructing the model using `Highs_addRow` and `Highs_addCol`.
*
* @param highs A pointer to the Highs instance.
* @param num_col The number of columns.
* @param num_row The number of rows.
* @param num_nz The number of elements in the constraint matrix.
* @param q_num_nz The number of elements in the Hessian matrix.
* @param a_format The format of the constraint matrix to use in the form of
* a `kHighsMatrixFormat` constant.
* @param q_format The format of the Hessian matrix to use in the form of a
* `kHighsHessianFormat` constant.
* @param sense The optimization sense in the form of a `kHighsObjSense`
* constant.
* @param offset The constant term in the objective function.
* @param col_cost An array of length [num_col] with the objective
* coefficients.
* @param col_lower An array of length [num_col] with the lower column bounds.
* @param col_upper An array of length [num_col] with the upper column bounds.
* @param row_lower An array of length [num_row] with the upper row bounds.
* @param row_upper An array of length [num_row] with the upper row bounds.
* @param a_start The constraint matrix is provided to HiGHS in compressed
* sparse column form (if `a_format` is
* `kHighsMatrixFormatColwise`, otherwise compressed sparse
* row form). The sparse matrix consists of three arrays,
* `a_start`, `a_index`, and `a_value`. `a_start` is an array
* of length [num_col] containing the starting index of each
* column in `a_index`. If `a_format` is
* `kHighsMatrixFormatRowwise` the array is of length
* [num_row] corresponding to each row.
* @param a_index An array of length [num_nz] with indices of matrix
* entries.
* @param a_value An array of length [num_nz] with values of matrix entries.
* @param q_start The Hessian matrix is provided to HiGHS as the lower
* triangular component in compressed sparse column form
* (or, equivalently, as the upper triangular component
* in compressed sparse row form). The sparse matrix consists
* of three arrays, `q_start`, `q_index`, and `q_value`.
* `q_start` is an array of length [num_col]. If the model
* is linear, pass NULL.
* @param q_index An array of length [q_num_nz] with indices of matrix
* entries. If the model is linear, pass NULL.
* @param q_value An array of length [q_num_nz] with values of matrix
* entries. If the model is linear, pass NULL.
* @param integrality An array of length [num_col] containing a `kHighsVarType`
* constant for each column.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passModel(void* highs, const HighsInt num_col,
const HighsInt num_row, const HighsInt num_nz,
const HighsInt q_num_nz, const HighsInt a_format,
const HighsInt q_format, const HighsInt sense,
const double offset, const double* col_cost,
const double* col_lower, const double* col_upper,
const double* row_lower, const double* row_upper,
const HighsInt* a_start, const HighsInt* a_index,
const double* a_value, const HighsInt* q_start,
const HighsInt* q_index, const double* q_value,
const HighsInt* integrality);
/**
* Set the Hessian matrix for a quadratic objective.
*
* @param highs A pointer to the Highs instance.
* @param dim The dimension of the Hessian matrix. Should be [num_col].
* @param num_nz The number of non-zero elements in the Hessian matrix.
* @param format The format of the Hessian matrix as a `kHighsHessianFormat`
* constant. This must be `kHighsHessianFormatTriangular`.
* @param start The Hessian matrix is provided to HiGHS as the lower
* triangular component in compressed sparse column form
* (or, equivalently, as the upper triangular component
* in compressed sparse row form), using `q_start`, `q_index`,
* and `q_value`.The Hessian matrix is provided to HiGHS as the
* lower triangular component in compressed sparse column form.
* The sparse matrix consists of three arrays, `start`,
* `index`, and `value`. `start` is an array of length
* [num_col] containing the starting index of each column in
* `index`.
* @param index An array of length [num_nz] with indices of matrix entries.
* @param value An array of length [num_nz] with values of matrix entries.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passHessian(void* highs, const HighsInt dim,
const HighsInt num_nz, const HighsInt format,
const HighsInt* start, const HighsInt* index,
const double* value);
/**
* Pass the name of a row.
*
* @param highs A pointer to the Highs instance.
* @param row The row for which the name is supplied.
* @param name The name of the row.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passRowName(const void* highs, const HighsInt row,
const char* name);
/**
* Pass the name of a column.
*
* @param highs A pointer to the Highs instance.
* @param col The column for which the name is supplied.
* @param name The name of the column.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passColName(const void* highs, const HighsInt col,
const char* name);
/**
* Pass the name of the model.
*
* @param highs A pointer to the Highs instance.
* @param name The name of the model.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_passModelName(const void* highs, const char* name);
/**
* Read the option values from file.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename from which to read the option values.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_readOptions(const void* highs, const char* filename);
/**
* Set a boolean-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The new value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_setBoolOptionValue(void* highs, const char* option,
const HighsInt value);
/**
* Set an int-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The new value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_setIntOptionValue(void* highs, const char* option,
const HighsInt value);
/**
* Set a double-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The new value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_setDoubleOptionValue(void* highs, const char* option,
const double value);
/**
* Set a string-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The new value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_setStringOptionValue(void* highs, const char* option,
const char* value);
/**
* Get a boolean-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The location in which the current value of the option should
* be placed.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getBoolOptionValue(const void* highs, const char* option,
HighsInt* value);
/**
* Get an int-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The location in which the current value of the option should
* be placed.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getIntOptionValue(const void* highs, const char* option,
HighsInt* value);
/**
* Get a double-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value The location in which the current value of the option should
* be placed.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getDoubleOptionValue(const void* highs, const char* option,
double* value);
/**
* Get a string-valued option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param value A pointer to allocated memory (of at least
* `kMaximumStringLength`) to store the current value of the
* option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getStringOptionValue(const void* highs, const char* option,
char* value);
/**
* Get the type expected by an option.
*
* @param highs A pointer to the Highs instance.
* @param option The name of the option.
* @param type An int in which the corresponding `kHighsOptionType`
* constant should be placed.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getOptionType(const void* highs, const char* option,
HighsInt* type);
/**
* Reset all options to their default value.
*
* @param highs A pointer to the Highs instance.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_resetOptions(void* highs);
/**
* Write the current options to file.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename to write the options to.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writeOptions(const void* highs, const char* filename);
/**
* Write the value of non-default options to file.
*
* This is similar to `Highs_writeOptions`, except only options with
* non-default value are written to `filename`.
*
* @param highs A pointer to the Highs instance.
* @param filename The filename to write the options to.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_writeOptionsDeviations(const void* highs, const char* filename);
/**
* Return the number of options
*
* @param highs A pointer to the Highs instance.
*/
HighsInt Highs_getNumOptions(const void* highs);
/**
* Get the name of an option identified by index
*
* @param highs A pointer to the Highs instance.
* @param index The index of the option.
* @param name The name of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getOptionName(const void* highs, const HighsInt index,
char** name);
/**
* Get the current and default values of a bool option
*
* @param highs A pointer to the Highs instance.
* @param current_value A pointer to the current value of the option.
* @param default_value A pointer to the default value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getBoolOptionValues(const void* highs, const char* option,
HighsInt* current_value,
HighsInt* default_value);
/**
* Get the current and default values of an int option
*
* @param highs A pointer to the Highs instance.
* @param current_value A pointer to the current value of the option.
* @param min_value A pointer to the minimum value of the option.
* @param max_value A pointer to the maximum value of the option.
* @param default_value A pointer to the default value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getIntOptionValues(const void* highs, const char* option,
HighsInt* current_value, HighsInt* min_value,
HighsInt* max_value, HighsInt* default_value);
/**
* Get the current and default values of a double option
*
* @param highs A pointer to the Highs instance.
* @param current_value A pointer to the current value of the option.
* @param min_value A pointer to the minimum value of the option.
* @param max_value A pointer to the maximum value of the option.
* @param default_value A pointer to the default value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getDoubleOptionValues(const void* highs, const char* option,
double* current_value, double* min_value,
double* max_value, double* default_value);
/**
* Get the current and default values of a string option
*
* @param highs A pointer to the Highs instance.
* @param current_value A pointer to the current value of the option.
* @param default_value A pointer to the default value of the option.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getStringOptionValues(const void* highs, const char* option,
char* current_value, char* default_value);
/**
* Get an int-valued info value.
*
* @param highs A pointer to the Highs instance.
* @param info The name of the info item.
* @param value A reference to an integer that the result will be stored in.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getIntInfoValue(const void* highs, const char* info,
HighsInt* value);
/**
* Get a double-valued info value.
*
* @param highs A pointer to the Highs instance.
* @param info The name of the info item.
* @param value A reference to a double that the result will be stored in.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getDoubleInfoValue(const void* highs, const char* info,
double* value);
/**
* Get an int64-valued info value.
*
* @param highs A pointer to the Highs instance.
* @param info The name of the info item.
* @param value A reference to an int64 that the result will be stored in.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getInt64InfoValue(const void* highs, const char* info,
int64_t* value);
/**
* Get the type expected by an info item.
*
* @param highs A pointer to the Highs instance.
* @param info The name of the info item.
* @param type An int in which the corresponding `kHighsOptionType`
* constant is stored.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getInfoType(const void* highs, const char* info, HighsInt* type);
/**
* Get the primal and dual solution from an optimized model.
*
* @param highs A pointer to the Highs instance.
* @param col_value An array of length [num_col], to be filled with primal
* column values.
* @param col_dual An array of length [num_col], to be filled with dual column
* values.
* @param row_value An array of length [num_row], to be filled with primal row
* values.
* @param row_dual An array of length [num_row], to be filled with dual row
* values.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getSolution(const void* highs, double* col_value,
double* col_dual, double* row_value,
double* row_dual);
/**
* Given a linear program with a basic feasible solution, get the column and row
* basis statuses.
*
* @param highs A pointer to the Highs instance.
* @param col_status An array of length [num_col], to be filled with the column
* basis statuses in the form of a `kHighsBasisStatus`
* constant.
* @param row_status An array of length [num_row], to be filled with the row
* basis statuses in the form of a `kHighsBasisStatus`
* constant.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getBasis(const void* highs, HighsInt* col_status,
HighsInt* row_status);
/**
* Return the optimization status of the model in the form of a
* `kHighsModelStatus` constant.
*
* @param highs A pointer to the Highs instance.
*
* @returns An integer corresponding to the `kHighsModelStatus` constant
*/
HighsInt Highs_getModelStatus(const void* highs);
/**
* Indicates whether a dual ray that is a certificate of primal
* infeasibility currently exists, and (at the expense of solving an
* LP) gets it if it does not and dual_ray_value is not nullptr.
*
* @param highs A pointer to the Highs instance.
* @param has_dual_ray A pointer to an int to store 1 if a dual ray
* currently exists.
* @param dual_ray_value An array of length [num_row] filled with the
* unbounded ray.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getDualRay(const void* highs, HighsInt* has_dual_ray,
double* dual_ray_value);
/**
* Indicates whether a dual unboundedness direction (corresponding to a
* certificate of primal infeasibility) exists, and (at the expense of
* solving an LP) gets it if it does not and
* dual_unboundedness_direction is not nullptr
*
* @param highs A pointer to the Highs
* instance.
* @param has_dual_unboundedness_direction A pointer to an int to store 1
* if the dual unboundedness
* direction exists.
* @param dual_unboundedness_direction_value An array of length [num_col]
* filled with the unboundedness
* direction.
*/
HighsInt getDualUnboundednessDirection(
const void* highs, HighsInt* has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value);
/**
* Indicates whether a primal ray that is a certificate of primal
* unboundedness currently exists, and (at the expense of solving an
* LP) gets it if it does not and primal_ray_value is not nullptr.
*
* @param highs A pointer to the Highs instance.
* @param has_primal_ray A pointer to an int to store 1 if the primal ray
* exists.
* @param primal_ray_value An array of length [num_col] filled with the
* unbounded ray.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getPrimalRay(const void* highs, HighsInt* has_primal_ray,
double* primal_ray_value);
/**
* Get the primal objective function value.
*
* @param highs A pointer to the Highs instance.
*
* @returns The primal objective function value
*/
double Highs_getObjectiveValue(const void* highs);
/**
* Get the indices of the rows and columns that make up the basis matrix ``B``
* of a basic feasible solution.
*
* Non-negative entries are indices of columns, and negative entries are
* `-row_index - 1`. For example, `{1, -1}` would be the second column and first
* row.
*
* The order of these rows and columns is important for calls to the functions:
*
* - `Highs_getBasisInverseRow`
* - `Highs_getBasisInverseCol`
* - `Highs_getBasisSolve`
* - `Highs_getBasisTransposeSolve`
* - `Highs_getReducedRow`
* - `Highs_getReducedColumn`
*
* @param highs A pointer to the Highs instance.
* @param basic_variables An array of size [num_rows], filled with the indices
* of the basic variables.
*
* @returns A `kHighsStatus` constant indicating whether the call succeeded.
*/
HighsInt Highs_getBasicVariables(const void* highs, HighsInt* basic_variables);