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

Function testMultiObjective

check/TestCAPI.c:1911–2026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1909}
1910
1911void testMultiObjective() {
1912 void* highs;
1913 highs = Highs_create();
1914 const double inf = Highs_getInfinity(highs);
1915
1916 HighsInt num_col = 2;
1917 HighsInt num_row = 3;
1918 HighsInt num_nz = num_col * num_row;
1919 HighsInt a_format = kHighsMatrixFormatColwise;
1920 HighsInt sense = kHighsObjSenseMaximize;
1921 double offset = -1;
1922 double col_cost[2] = {1, 1};
1923 double col_lower[2] = {0, 0};
1924 double col_upper[2] = {inf, inf};
1925 double row_lower[3] = {-inf, -inf, -inf};
1926 double row_upper[3] = {18, 8, 14};
1927 HighsInt a_start[3] = {0, 3, 6};
1928 HighsInt a_index[6] = {0, 1, 2, 0, 1, 2};
1929 double a_value[6] = {3, 1, 1, 1, 1, 2};
1930
1931 Highs_setBoolOptionValue(highs, "output_flag", dev_run);
1932 HighsInt return_status = Highs_passLp(
1933 highs, num_col, num_row, num_nz, a_format, sense, offset, col_cost,
1934 col_lower, col_upper, row_lower, row_upper, a_start, a_index, a_value);
1935 assert(return_status == kHighsStatusOk);
1936
1937 return_status = Highs_clearLinearObjectives(highs);
1938 assert(return_status == kHighsStatusOk);
1939
1940 double weight = -1;
1941 double linear_objective_offset = -1;
1942 double coefficients[2] = {1, 1};
1943 double abs_tolerance = 0;
1944 double rel_tolerance = 0;
1945 HighsInt priority = 10;
1946 return_status = Highs_addLinearObjective(
1947 highs, weight, linear_objective_offset, coefficients, abs_tolerance,
1948 rel_tolerance, priority);
1949 assert(return_status == kHighsStatusOk);
1950
1951 weight = 1e-4;
1952 linear_objective_offset = 0;
1953 coefficients[0] = 1;
1954 coefficients[1] = 0;
1955 priority = 0;
1956 return_status = Highs_addLinearObjective(
1957 highs, weight, linear_objective_offset, coefficients, abs_tolerance,
1958 rel_tolerance, priority);
1959 assert(return_status == kHighsStatusOk);
1960
1961 return_status = Highs_run(highs);
1962 assert(return_status == kHighsStatusOk);
1963 HighsInt model_status = Highs_getModelStatus(highs);
1964 assert(model_status == kHighsModelStatusOptimal);
1965
1966 Highs_writeSolutionPretty(highs, "");
1967 double* col_value = (double*)malloc(sizeof(double) * num_col);
1968 return_status = Highs_getSolution(highs, col_value, NULL, NULL, NULL);

Callers 1

mainFunction · 0.85

Calls 13

Highs_createFunction · 0.85
Highs_getInfinityFunction · 0.85
Highs_setBoolOptionValueFunction · 0.85
Highs_passLpFunction · 0.85
Highs_addLinearObjectiveFunction · 0.85
Highs_runFunction · 0.85
Highs_getModelStatusFunction · 0.85
Highs_getSolutionFunction · 0.85
assertDoubleValuesEqualFunction · 0.85

Tested by

no test coverage detected