-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathHighs.h
1703 lines (1431 loc) · 57.8 KB
/
Highs.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 */
/* */
/* Available as open-source under the MIT License */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**@file Highs.h
* @brief The HiGHS class
*/
#ifndef HIGHS_H_
#define HIGHS_H_
#include <sstream>
#include "lp_data/HighsCallback.h"
#include "lp_data/HighsIis.h"
#include "lp_data/HighsLpUtils.h"
#include "lp_data/HighsRanging.h"
#include "lp_data/HighsSolutionDebug.h"
#include "model/HighsModel.h"
#include "presolve/ICrash.h"
#include "presolve/PresolveComponent.h"
/**
* @brief Return the version
*/
const char* highsVersion();
/**
* @brief Return detailed version information, githash and compilation
* date
*/
HighsInt highsVersionMajor();
HighsInt highsVersionMinor();
HighsInt highsVersionPatch();
const char* highsGithash();
/**
* @brief Class to set parameters and run HiGHS
*/
class Highs {
public:
Highs();
virtual ~Highs() {
FILE* log_stream = options_.log_options.log_stream;
if (log_stream != nullptr) {
assert(log_stream != stdout);
fclose(log_stream);
}
}
/**
* @brief Return the version as a string
*/
std::string version() const { return highsVersion(); }
/**
* @brief Return major version
*/
HighsInt versionMajor() const { return highsVersionMajor(); }
/**
* @brief Return minor version
*/
HighsInt versionMinor() const { return highsVersionMinor(); }
/**
* @brief Return patch version
*/
HighsInt versionPatch() const { return highsVersionPatch(); }
/**
* @brief Return githash
*/
std::string githash() const { return highsGithash(); }
/**
* @brief Reset the options and then call clearModel()
*/
HighsStatus clear();
/**
* @brief Clear the incumbent model and then call clearSolver()
*/
HighsStatus clearModel();
/**
* @brief Clear all solution data associated with the model
*/
HighsStatus clearSolver();
/**
* Methods for model input
*/
/**
* Every model loading module eventually uses
* passModel(HighsModel model) to communicate the model to HiGHS.
*/
/**
* @brief Pass a HighsModel instance to Highs
*/
HighsStatus passModel(HighsModel model);
/**
* @brief Pass a HighsLp instance to Highs
*/
HighsStatus passModel(HighsLp lp);
/**
* @brief Pass a QP (possibly with integrality data) via pointers to vectors
* of data
*/
HighsStatus passModel(
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 = nullptr);
/**
* @brief Pass an LP (possibly with integrality data) via pointers to vectors
* of data
*/
HighsStatus passModel(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 = nullptr);
/**
* @brief Pass a HighsHessian instance for the incumbent model
*/
HighsStatus passHessian(HighsHessian hessian_);
/**
* @brief Pass the Hessian for the incumbent model via pointers to vectors of
* data
*/
HighsStatus passHessian(const HighsInt dim, const HighsInt num_nz,
const HighsInt format, const HighsInt* start,
const HighsInt* index, const double* value);
/**
* @brief Pass multiple linear objectives for the incumbent model
*/
HighsStatus passLinearObjectives(
const HighsInt num_linear_objective,
const HighsLinearObjective* linear_objective);
/**
* @brief Add a linear objective for the incumbent model
*/
HighsStatus addLinearObjective(const HighsLinearObjective& linear_objective,
const HighsInt iObj = -1);
/**
* @brief Clear the multiple linear objective data
*/
HighsStatus clearLinearObjectives();
/**
* @brief Pass a column name to the incumbent model
*/
HighsStatus passColName(const HighsInt col, const std::string& name);
/**
* @brief Pass a row name to the incumbent model
*/
HighsStatus passRowName(const HighsInt row, const std::string& name);
/**
* @brief Pass a model name to the incumbent model
*/
HighsStatus passModelName(const std::string& name);
/**
* @brief Read in a model
*/
HighsStatus readModel(const std::string& filename);
/**
* @brief Read in a basis
*/
HighsStatus readBasis(const std::string& filename);
/**
* @brief Presolve the incumbent model, allowing the presolved model
* to be extracted. Subsequent solution of the incumbent model will
* only use presolve if there is no valid basis
*/
HighsStatus presolve();
/**
* @brief Run the solver, accounting for any multiple objective
*/
HighsStatus run();
/**
* @brief Postsolve the incumbent model using a solution
*/
HighsStatus postsolve(const HighsSolution& solution);
/**
* @brief Postsolve the incumbent model using a solution and basis
*/
HighsStatus postsolve(const HighsSolution& solution, const HighsBasis& basis);
/**
* @brief Write the current solution to a file in a given style
*/
HighsStatus writeSolution(const std::string& filename,
const HighsInt style = kSolutionStyleRaw);
/**
* @brief Read a HiGHS solution file in a given style
*/
HighsStatus readSolution(const std::string& filename,
const HighsInt style = kSolutionStyleRaw);
/**
* @brief Assess the validity, integrality and feasibility of the
* current primal solution. Of value after calling
* Highs::readSolution
*/
HighsStatus assessPrimalSolution(bool& valid, bool& integral,
bool& feasible) const;
/**
* Methods for HiGHS option input/output
*/
/**
* @brief Set an option to the bool/HighsInt/double/string value if it's
* legal and, for bool/HighsInt/double, only if it's of the correct type
*/
HighsStatus setOptionValue(const std::string& option, const bool value);
HighsStatus setOptionValue(const std::string& option, const HighsInt value);
#ifdef HIGHSINT64
HighsStatus setOptionValue(const std::string& option, const int value) {
return setOptionValue(option, HighsInt{value});
}
#endif
HighsStatus setOptionValue(const std::string& option, const double value);
HighsStatus setOptionValue(const std::string& option,
const std::string& value);
HighsStatus setOptionValue(const std::string& option, const char* value);
/**
* @brief Read option values from a file
*/
HighsStatus readOptions(const std::string& filename);
/**
* @brief Pass a HighsOptions instance to Highs
*/
HighsStatus passOptions(const HighsOptions& options);
/**
* @brief Get a const reference to the internal option values
*/
const HighsOptions& getOptions() const { return options_; }
/**
* @brief Gets an option value as bool/HighsInt/double/string and, for
* bool/int/double, only if it's of the correct type.
*
* NB Deprecate in v2.0, in order to replace with more general
* get*OptionValues
*/
HighsStatus getOptionValue(const std::string& option, bool& value) const {
return this->getBoolOptionValues(option, &value);
}
HighsStatus getOptionValue(const std::string& option, HighsInt& value) const {
return this->getIntOptionValues(option, &value);
}
HighsStatus getOptionValue(const std::string& option, double& value) const {
return this->getDoubleOptionValues(option, &value);
}
HighsStatus getOptionValue(const std::string& option,
std::string& value) const {
return this->getStringOptionValues(option, &value);
}
/**
* @brief Get the type expected by an option
*/
HighsStatus getOptionType(const std::string& option,
HighsOptionType& type) const {
return this->getOptionType(option, &type);
}
/**
* @brief Reset the options to the default values
*/
HighsStatus resetOptions();
/**
* @brief Write (deviations from default values of) the options to a
* file, using the standard format used to read options from a file.
* Possible to write only deviations from default values.
*/
HighsStatus writeOptions(const std::string& filename, //!< The filename
const bool report_only_deviations = false);
/**
* @brief Returns the number of user-settable options
*/
HighsInt getNumOptions() const {
return this->options_.num_user_settable_options_;
}
/**
* @brief Get the number of user-settable options
*/
HighsStatus getOptionName(const HighsInt index, std::string* name) const;
/**
* @brief Get the type of an option
*/
HighsStatus getOptionType(const std::string& option,
HighsOptionType* type) const;
/**
* @brief Get the current and default values of a bool option
*/
HighsStatus getBoolOptionValues(const std::string& option,
bool* current_value = nullptr,
bool* default_value = nullptr) const;
/**
* @brief Get the current, min, max and default values of an int option
*/
HighsStatus getIntOptionValues(const std::string& option,
HighsInt* current_value = nullptr,
HighsInt* min_value = nullptr,
HighsInt* max_value = nullptr,
HighsInt* default_value = nullptr) const;
/**
* @brief Get the current, min, max and default values of a double option
*/
HighsStatus getDoubleOptionValues(const std::string& option,
double* current_value = nullptr,
double* min_value = nullptr,
double* max_value = nullptr,
double* default_value = nullptr) const;
/**
* @brief Get the current and default values of a string option
*/
HighsStatus getStringOptionValues(const std::string& option,
std::string* current_value = nullptr,
std::string* default_value = nullptr) const;
/**
* @brief Get a const reference to the internal info values
* type.
*/
const HighsInfo& getInfo() const { return info_; }
/**
* @brief Get an info value as HighsInt/int64_t/double, and only if
* it's of the correct type.
*/
HighsStatus getInfoValue(const std::string& info, HighsInt& value) const;
#ifndef HIGHSINT64
HighsStatus getInfoValue(const std::string& info, int64_t& value) const;
#endif
HighsStatus getInfoValue(const std::string& info, double& value) const;
HighsStatus getInfoType(const std::string& info, HighsInfoType& type) const;
/**
* @brief Write info values to a file, with the extension ".html"
* producing HTML, otherwise using the standard format used to read
* options from a file.
*/
HighsStatus writeInfo(const std::string& filename = "") const;
/**
* @brief Get the value of infinity used by HiGHS
*/
double getInfinity() const { return kHighsInf; }
/**
* @brief Get the size of HighsInt
*/
HighsInt getSizeofHighsInt() const {
return sizeof(options_.num_user_settable_options_);
}
/**
* @brief Get the run time of HiGHS
*/
double getRunTime() const { return timer_.read(); }
/**
* Methods for model output
*/
/**
* @brief Identify the standard form of the HighsLp instance in
* HiGHS
*/
HighsStatus getStandardFormLp(HighsInt& num_col, HighsInt& num_row,
HighsInt& num_nz, double& offset,
double* cost = nullptr, double* rhs = nullptr,
HighsInt* start = nullptr,
HighsInt* index = nullptr,
double* value = nullptr);
/**
* @brief Return a const reference to the presolved HighsLp instance in HiGHS
*/
const HighsLp& getPresolvedLp() const { return presolved_model_.lp_; }
/**
* @brief Return a const reference to the presolved HighsModel instance in
* HiGHS
*/
const HighsModel& getPresolvedModel() const { return presolved_model_; }
/**
* @brief Return a const reference to the logging data for presolve
*/
const HighsPresolveLog& getPresolveLog() const { return presolve_log_; }
/**
* @brief Return a const pointer to the original column indices for
* the presolved model
*/
const HighsInt* getPresolveOrigColsIndex() const {
return presolve_.data_.postSolveStack.getOrigColsIndex();
}
/**
* @brief Return a const pointer to the original row indices for the
* presolved model
*/
const HighsInt* getPresolveOrigRowsIndex() const {
return presolve_.data_.postSolveStack.getOrigRowsIndex();
}
/**
* @brief Return a const reference to the incumbent LP
*/
const HighsLp& getLp() const { return model_.lp_; }
/**
* @brief Return a const reference to the incumbent model
*/
const HighsModel& getModel() const { return model_; }
/**
* @brief Return a const reference to the internal HighsSolution instance
*/
const HighsSolution& getSolution() const { return solution_; }
/**
* @brief Zero all clocks in the internal HighsTimer instance
*/
void zeroAllClocks() { timer_.zeroAllClocks(); };
/**
* @brief Return a const reference to the internal HighsSolution instance
*/
const std::vector<HighsObjectiveSolution>& getSavedMipSolutions() const {
return saved_objective_and_solution_;
}
/**
* @brief Return a const reference to the internal ICrash info instance
*/
const ICrashInfo& getICrashInfo() const { return icrash_info_; };
/**
* @brief Return a const reference to the internal HighsBasis instance
*/
const HighsBasis& getBasis() const { return basis_; }
/**
* @brief Return the status for the incumbent model.
*/
const HighsModelStatus& getModelStatus() const { return model_status_; }
/**
* @brief Returns the current model's presolve status
*/
const HighsPresolveStatus& getModelPresolveStatus() const {
return model_presolve_status_;
}
/**
* @brief Indicate whether a dual unbounded ray exists, and (at the
* expense of solving an LP) gets it if it does not and
* dual_ray_value is not nullptr
*/
HighsStatus getDualRay(bool& has_dual_ray, double* dual_ray_value = nullptr);
/**
* @brief Indicate whether a dual unbounded ray exists, and gets it
* if it does
*/
HighsStatus getDualRaySparse(bool& has_dual_ray, HVector& row_ep_buffer);
/**
* @brief Indicate whether a dual unboundedness direction exists,
* and (at the expense of solving an LP) gets it if
* dual_unboundedness_direction is not nullptr
*/
HighsStatus getDualUnboundednessDirection(
bool& has_dual_unboundedness_direction,
double* dual_unboundedness_direction_value = nullptr);
/**
* @brief Indicate whether a primal unbounded ray exists, and (at
* the expense of solving an LP) gets it if primal_ray is not
* nullptr
*/
HighsStatus getPrimalRay(bool& has_primal_ray,
double* primal_ray_value = nullptr);
/**
* @brief Get the ranging information for the current LP
*/
HighsStatus getRanging(HighsRanging& ranging);
/**
* @brief Solve the feasibility relaxation problem
*/
HighsStatus feasibilityRelaxation(const double global_lower_penalty,
const double global_upper_penalty,
const double global_rhs_penalty,
const double* local_lower_penalty = nullptr,
const double* local_upper_penalty = nullptr,
const double* local_rhs_penalty = nullptr);
/**
* @brief Get the ill-conditioning information for the current basis
*/
HighsStatus getIllConditioning(HighsIllConditioning& ill_conditioning,
const bool constraint,
const HighsInt method = 0,
const double ill_conditioning_bound = 1e-4);
/**
* @brief Get (any) irreducible infeasible subsystem (IIS)
* information for the incumbent model
*/
HighsStatus getIis(HighsIis& iis);
/**
* @brief Get the current model objective function value
*/
double getObjectiveValue() const { return info_.objective_function_value; }
/**
* @brief Try to get the current dual objective function value
*/
HighsStatus getDualObjectiveValue(double& dual_objective_value) const;
/**
* Methods for operations with the invertible representation of the
* current basis matrix
*/
/**
* @brief Returns true if an invertible representation of the
* current basis matrix is available
*/
bool hasInvert() const;
/**
* @brief Gets the basic variables in the order corresponding to
* calls to getBasisInverseRow, getBasisInverseCol, getBasisSolve,
* getBasisTransposeSolve, getReducedRow and
* getReducedColumn. Non-negative entries are indices of columns,
* and negative entries are -(row_index+1).
*/
HighsStatus getBasicVariables(HighsInt* basic_variables);
/**
* @brief Form a row of \f$B^{-1}\f$ for basis matrix \f$B\f$,
* returning the indices of the nonzeros unless row_num_nz is
* nullptr
*/
HighsStatus getBasisInverseRow(const HighsInt row, double* row_vector,
HighsInt* row_num_nz = nullptr,
HighsInt* row_indices = nullptr);
/**
* @brief Form a column of \f$B^{-1}\f$ for basis matrix \f$B\f$,
* returning the indices of the nonzeros unless col_num_nz is
* nullptr
*/
HighsStatus getBasisInverseCol(const HighsInt col, double* col_vector,
HighsInt* col_num_nz = nullptr,
HighsInt* col_indices = nullptr);
/**
* @brief Form \f$\mathbf{x}=B^{-1}\mathbf{b}\f$ for a given vector
* \f$\mathbf{b}\f$, returning the indices of the nonzeros unless
* solution_num_nz is nullptr
*/
HighsStatus getBasisSolve(const double* rhs, double* solution_vector,
HighsInt* solution_num_nz = nullptr,
HighsInt* solution_indices = nullptr);
/**
* @brief Form \f$\mathbf{x}=B^{-T}\mathbf{b}\f$ for a given vector
* \f$\mathbf{b}\f$, returning the indices of the nonzeros unless
* solution_num_nz is nullptr
*/
HighsStatus getBasisTransposeSolve(const double* rhs, double* solution_vector,
HighsInt* solution_num_nz = nullptr,
HighsInt* solution_indices = nullptr);
/**
* @brief Form a row of \f$B^{-1}A\f$, returning the indices of the
* nonzeros unless row_num_nz is nullptr, computing the row using
* pass_basis_inverse_row_vector unless it is nullptr
*/
HighsStatus getReducedRow(
const HighsInt row, double* row_vector, HighsInt* row_num_nz = nullptr,
HighsInt* row_indices = nullptr,
const double* pass_basis_inverse_row_vector = nullptr);
/**
* @brief Form a column of \f$B^{-1}A\f$, returning the indices of
* the nonzeros unless col_num_nz is nullptr
*/
HighsStatus getReducedColumn(const HighsInt col, double* col_vector,
HighsInt* col_num_nz = nullptr,
HighsInt* col_indices = nullptr);
/**
* @brief Get the condition number of the current basis matrix,
* possibly computing it exactly and reporting the error in the
* approximate condition number
*/
HighsStatus getKappa(double& kappa, const bool exact = false,
const bool report = false) const;
/**
* @brief Get the number of columns in the incumbent model
*/
HighsInt getNumCol() const { return model_.lp_.num_col_; }
/**
* @brief Get the number of rows in the incumbent model
*/
HighsInt getNumRow() const { return model_.lp_.num_row_; }
/**
* @brief Get the number of (constraint matrix) nonzeros in the incumbent
* model
*/
HighsInt getNumNz() const { return model_.lp_.a_matrix_.numNz(); }
/**
* @brief Get the number of Hessian matrix nonzeros in the incumbent model
*/
HighsInt getHessianNumNz() const { return model_.hessian_.numNz(); }
/**
* @brief Get the objective sense of the incumbent model
*/
HighsStatus getObjectiveSense(ObjSense& sense) const;
/**
* @brief Get the objective offset of the incumbent model
*/
HighsStatus getObjectiveOffset(double& offset) const;
/**
* @brief Get multiple columns from the model given by an interval [from_col,
* to_col]
*/
HighsStatus getCols(
const HighsInt
from_col, //!< The index of the first column to get from the model
const HighsInt
to_col, //!< The index of the last column to get from the model
HighsInt& num_col, //!< Number of columns got from the model
double* cost, //!< Array of size num_col with costs
double* lower, //!< Array of size num_col with lower bounds
double* upper, //!< Array of size num_col with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_col with start indices of the columns
HighsInt*
index, //!< Array of size num_nz with row indices for the columns
double* value //!< Array of size num_nz with row values for the columns
) const;
/**
* @brief Get multiple columns from the model given by a set
*/
HighsStatus getCols(
const HighsInt num_set_entries, //!< The number of indices in the set
const HighsInt* set, //!< Array of size num_set_entries with indices of
//!< columns to get
HighsInt& num_col, //!< Number of columns got from the model
double* cost, //!< Array of size num_col with costs
double* lower, //!< Array of size num_col with lower bounds
double* upper, //!< Array of size num_col with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_col with start indices of the columns
HighsInt*
index, //!< Array of size num_nz with row indices for the columns
double* value //!< Array of size num_nz with row values for the columns
) const;
/**
* @brief Get multiple columns from the model given by a mask
*/
HighsStatus getCols(
const HighsInt* mask, //!< Full length array with 1 => get; 0 => not
HighsInt& num_col, //!< Number of columns got from the model
double* cost, //!< Array of size num_col with cost
double* lower, //!< Array of size num_col with lower bounds
double* upper, //!< Array of size num_col with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_col with start indices of the columns
HighsInt*
index, //!< Array of size num_nz with row indices for the columns
double* value //!< Array of size num_nz with row values for the columns
) const;
/**
* @brief Get a column name from the incumbent model
*/
HighsStatus getColName(const HighsInt col, std::string& name) const;
/**
* @brief Get column index corresponding to name
*/
HighsStatus getColByName(const std::string& name, HighsInt& col);
/**
* @brief Get a column integrality from the incumbent model
*/
HighsStatus getColIntegrality(const HighsInt col,
HighsVarType& integrality) const;
/**
* @brief Get multiple rows from the model given by an interval [from_row,
* to_row]
*/
HighsStatus getRows(
const HighsInt
from_row, //!< The index of the first row to get from the model
const HighsInt
to_row, //!< The index of the last row to get from the model
HighsInt& num_row, //!< Number of rows got from the model
double* lower, //!< Array of size num_row with lower bounds
double* upper, //!< Array of size num_row with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_row with start indices of the rows
HighsInt*
index, //!< Array of size num_nz with column indices for the rows
double* value //!< Array of size num_nz with column values for the rows
) const;
/**
* @brief Get multiple rows from the model given by a set
*/
HighsStatus getRows(
const HighsInt num_set_entries, //!< The number of indices in the set
const HighsInt*
set, //!< Array of size num_set_entries with indices of rows to get
HighsInt& num_row, //!< Number of rows got from the model
double* lower, //!< Array of size num_row with lower bounds
double* upper, //!< Array of size num_row with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_row with start indices of the rows
HighsInt*
index, //!< Array of size num_nz with column indices for the rows
double* value //!< Array of size num_nz with column values for the rows
) const;
/**
* @brief Get multiple rows from the model given by a mask
*/
HighsStatus getRows(
const HighsInt* mask, //!< Full length array with 1 => get; 0 => not
HighsInt& num_row, //!< Number of rows got from the model
double* lower, //!< Array of size num_row with lower bounds
double* upper, //!< Array of size num_row with upper bounds
HighsInt& num_nz, //!< Number of nonzeros got from the model
HighsInt*
start, //!< Array of size num_row with start indices of the rows
HighsInt*
index, //!< Array of size num_nz with column indices for the rows
double* value //!< Array of size num_nz with column values for the rows
) const;
/**
* @brief Get a row name from the incumbent model
*/
HighsStatus getRowName(const HighsInt row, std::string& name) const;
/**
* @brief Get row index corresponding to name
*/
HighsStatus getRowByName(const std::string& name, HighsInt& row);
/**
* @brief Get a matrix coefficient
*/
HighsStatus getCoeff(const HighsInt row, const HighsInt col,
double& value) const;
/**
* @brief Write out the incumbent model to a file
*/
HighsStatus writeModel(const std::string& filename = "");
/**
* @brief Write out the incumbent presolved model to a file
*/
HighsStatus writePresolvedModel(const std::string& filename = "");
/**
* @brief Write out the given model to a file
*/
HighsStatus writeLocalModel(HighsModel& model,
const std::string& filename = "");
/**
* @brief Write out the internal HighsBasis instance to a file
*/
HighsStatus writeBasis(const std::string& filename = "") const;
/**
* Methods for incumbent model modification
*/
/**
* @brief Change the objective sense of the incumbent model
*/
HighsStatus changeObjectiveSense(const ObjSense sense);
/**
* @brief Change the objective offset of the incumbent model
*/
HighsStatus changeObjectiveOffset(const double offset);
/**
* @brief Change the integrality of a column
*/
HighsStatus changeColIntegrality(const HighsInt col,
const HighsVarType integrality);
/**
* @brief Change the integrality of multiple columns given by an
* interval [from_col, to_col]
*/
HighsStatus changeColsIntegrality(const HighsInt from_col,
const HighsInt to_col,
const HighsVarType* integrality);
/**
* @brief Change the integrality of multiple columns given by a set of indices
*/
HighsStatus changeColsIntegrality(const HighsInt num_set_entries,
const HighsInt* set,
const HighsVarType* integrality);
/**
* @brief Change the integrality of multiple columns given by a mask
* (full length array with 1 => change; 0 => not)
*/
HighsStatus changeColsIntegrality(const HighsInt* mask,
const HighsVarType* integrality);
/**
* @brief Clear the integrality of all columns
*/
HighsStatus clearIntegrality() {
this->model_.lp_.integrality_.clear();
return HighsStatus::kOk;
}
/**
* @brief Change the cost of a column
*/
HighsStatus changeColCost(const HighsInt col, const double cost);
/**
* @brief Change the cost of multiple columns given by an interval [from_col,
* to_col]
*/
HighsStatus changeColsCost(const HighsInt from_col, const HighsInt to_col,
const double* cost);
/**
* @brief Change the cost of multiple columns given by a set of indices
*/
HighsStatus changeColsCost(const HighsInt num_set_entries,
const HighsInt* set, const double* cost);
/**
* @brief Change the cost of multiple columns given by a mask
* (full length array with 1 => change; 0 => not)
*/
HighsStatus changeColsCost(const HighsInt* mask, const double* cost);
/**
* @brief Change the bounds of a column
*/
HighsStatus changeColBounds(const HighsInt col, const double lower,
const double upper);
/**
* @brief Change the bounds of multiple columns given by an interval
* [from_col, to_col]
*/
HighsStatus changeColsBounds(const HighsInt from_col, const HighsInt to_col,
const double* lower, const double* upper);
/**
* @brief Change the bounds of multiple columns given by a set of indices
*/
HighsStatus changeColsBounds(const HighsInt num_set_entries,
const HighsInt* set, const double* lower,
const double* upper);
/**
* @brief Change the cost of multiple columns given by a mask (full
* length array with 1 => change; 0 => not)
*/
HighsStatus changeColsBounds(const HighsInt* mask, const double* lower,
const double* upper);
/**
* @brief Change the bounds of a row
*/
HighsStatus changeRowBounds(const HighsInt row, const double lower,
const double upper);
/**
* @brief Change the bounds of multiple rows given by an interval [from_row,
* to_row]
*/
HighsStatus changeRowsBounds(const HighsInt from_row, const HighsInt to_row,
const double* lower, const double* upper);
/**
* @brief Change the bounds of multiple rows given by a set of indices
*/
HighsStatus changeRowsBounds(const HighsInt num_set_entries,
const HighsInt* set, const double* lower,
const double* upper);
/**
* @brief Change the cost of multiple rows given by a mask (full
* length array with 1 => change; 0 => not)
*/
HighsStatus changeRowsBounds(const HighsInt* mask, const double* lower,
const double* upper);
/**
* @brief Change a matrix coefficient
*/
HighsStatus changeCoeff(const HighsInt row, const HighsInt col,
const double value);
/**
* @brief Sets the constraint matrix format of the incumbent model
*/
HighsStatus setMatrixFormat(const MatrixFormat desired_format) {
this->model_.lp_.setFormat(desired_format);
return HighsStatus::kOk;
}
/**
* @brief Adds a variable to the incumbent model, without the matrix