MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / testGetModel

Function testGetModel

check/TestCAPI.c:1813–1909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1811}
1812
1813void testGetModel() {
1814 void* highs;
1815 highs = Highs_create();
1816 Highs_setBoolOptionValue(highs, "output_flag", dev_run);
1817 const double inf = Highs_getInfinity(highs);
1818
1819 HighsInt num_col = 2;
1820 HighsInt num_row = 2;
1821 HighsInt num_nz = 4;
1822 HighsInt sense = -1;
1823 double col_cost[2] = {8, 10};
1824 double col_lower[2] = {0, 0};
1825 double col_upper[2] = {inf, inf};
1826 double row_lower[2] = {-inf, -inf};
1827 double row_upper[2] = {120, 210};
1828 HighsInt a_index[4] = {0, 1, 0, 1};
1829 double a_value[4] = {0.3, 0.5, 0.7, 0.5};
1830 HighsInt a_start[2] = {0, 2};
1831 Highs_addVars(highs, num_col, col_lower, col_upper);
1832 Highs_changeColsCostByRange(highs, 0, num_col - 1, col_cost);
1833 Highs_addRows(highs, num_row, row_lower, row_upper, num_nz, a_start, a_index,
1834 a_value);
1835 Highs_changeObjectiveSense(highs, sense);
1836
1837 assert(Highs_getNumCols(highs) == num_col);
1838 assert(Highs_getNumRows(highs) == num_row);
1839 assert(Highs_getNumNz(highs) == num_nz);
1840 assert(Highs_getHessianNumNz(highs) == 0);
1841
1842 HighsInt ck_num_col;
1843 HighsInt ck_num_row;
1844 HighsInt ck_num_nz;
1845 HighsInt ck_sense;
1846 double ck_offset;
1847 HighsInt a_format = kHighsMatrixFormatRowwise;
1848
1849 // Get the model dimensions by passing array pointers as NULL
1850 HighsInt return_status;
1851 return_status = Highs_getLp(highs, a_format, &ck_num_col, &ck_num_row,
1852 &ck_num_nz, &ck_sense, &ck_offset, NULL, NULL, NULL, NULL, NULL,
1853 NULL, NULL, NULL, NULL);
1854 assert(return_status == kHighsStatusOk);
1855
1856 assert(ck_num_col == num_col);
1857 assert(ck_num_row == num_row);
1858 assert(ck_num_nz == num_nz);
1859 // Motivated by #1712, ensure that the correct sense is returned when
1860 // maximizing
1861 assert(ck_sense == sense);
1862
1863 double* ck_col_cost = (double*)malloc(sizeof(double) * ck_num_col);
1864 double* ck_col_lower = (double*)malloc(sizeof(double) * ck_num_col);
1865 double* ck_col_upper = (double*)malloc(sizeof(double) * ck_num_col);
1866 double* ck_row_lower = (double*)malloc(sizeof(double) * ck_num_row);
1867 double* ck_row_upper = (double*)malloc(sizeof(double) * ck_num_row);
1868 HighsInt* ck_a_start = (HighsInt*)malloc(sizeof(HighsInt) * ck_num_col);
1869 HighsInt* ck_a_index = (HighsInt*)malloc(sizeof(HighsInt) * ck_num_nz);
1870 double* ck_a_value = (double*)malloc(sizeof(double) * num_nz);

Callers 1

mainFunction · 0.85

Calls 15

Highs_createFunction · 0.85
Highs_setBoolOptionValueFunction · 0.85
Highs_getInfinityFunction · 0.85
Highs_addVarsFunction · 0.85
Highs_addRowsFunction · 0.85
Highs_getNumColsFunction · 0.85
Highs_getNumRowsFunction · 0.85
Highs_getNumNzFunction · 0.85
Highs_getHessianNumNzFunction · 0.85
Highs_getLpFunction · 0.85

Tested by

no test coverage detected