99#include <math.h>
1010#include <string.h>
1111
12- const HighsInt dev_run = 0 ;
12+ const HighsInt dev_run = 1 ;
1313const double double_equal_tolerance = 1e-5 ;
1414
1515void checkGetCallbackDataOutPointer (const HighsCallbackDataOut * data_out ,
@@ -238,6 +238,27 @@ void assertLogical(const char* name, const HighsInt is) {
238238 }
239239}
240240
241+ void createTestLp (void * highs ) {
242+ HighsInt num_col = 2 ;
243+ HighsInt num_row = 2 ;
244+ HighsInt num_nz = 4 ;
245+ HighsInt a_format = kHighsMatrixFormatRowwise ;
246+ HighsInt sense = kHighsObjSenseMinimize ;
247+ double offset = 0 ;
248+ double cc [2 ] = {1.0 , -2.0 };
249+ double cl [2 ] = {0.0 , 0.0 };
250+ double cu [2 ] = {10.0 , 10.0 };
251+ double rl [2 ] = {0.0 , 0.0 };
252+ double ru [2 ] = {2.0 , 1.0 };
253+ HighsInt a_start [3 ] = {0 , 2 , 4 };
254+ HighsInt a_index [4 ] = {0 , 1 , 0 , 1 };
255+ double a_value [4 ] = {1.0 , 2.0 , 1.0 , 3.0 };
256+
257+ assert (Highs_addCols (highs , 2 , cc , cl , cu , 0 , NULL , NULL , NULL ) == 0 );
258+ assert (Highs_addRows (highs , 2 , rl , ru , 4 , a_start , a_index , a_value ) == 0 );
259+ }
260+
261+ // Test methods
241262void versionApi () {
242263 if (dev_run ) {
243264 printf ("HiGHS version %s\n" , Highs_version ());
@@ -530,74 +551,22 @@ void minimalApiIllegalLp() {
530551 assert (model_status == kHighsModelStatusNotset );
531552}
532553
533- void fullApi () {
554+ void testNames () {
534555 void * highs = Highs_create ();
535556
536557 if (!dev_run ) Highs_setBoolOptionValue (highs , "output_flag" , 0 );
537558
538- HighsInt num_col = 2 ;
539- HighsInt num_row = 2 ;
540- HighsInt num_nz = 4 ;
541- HighsInt a_format = kHighsMatrixFormatRowwise ;
542- HighsInt sense = kHighsObjSenseMinimize ;
543- double offset = 0 ;
544- double cc [2 ] = {1.0 , -2.0 };
545- double cl [2 ] = {0.0 , 0.0 };
546- double cu [2 ] = {10.0 , 10.0 };
547- double rl [2 ] = {0.0 , 0.0 };
548- double ru [2 ] = {2.0 , 1.0 };
549- HighsInt a_start [3 ] = {0 , 2 , 4 };
550- HighsInt a_index [4 ] = {0 , 1 , 0 , 1 };
551- double a_value [4 ] = {1.0 , 2.0 , 1.0 , 3.0 };
552-
553- assert (Highs_addCols (highs , 2 , cc , cl , cu , 0 , NULL , NULL , NULL ) == 0 );
554- assert (Highs_addRows (highs , 2 , rl , ru , 4 , a_start , a_index , a_value ) == 0 );
559+ createTestLp (highs );
555560
556- assert (Highs_getNumCols (highs ) == num_col );
557- assert (Highs_getNumRows (highs ) == num_row );
558- assert (Highs_getNumNz (highs ) == num_nz );
559- assert (Highs_getHessianNumNz (highs ) == 0 );
560-
561- HighsInt ck_num_col ;
562- HighsInt ck_num_row ;
563- HighsInt ck_num_nz ;
564- HighsInt ck_sense ;
565- double ck_offset ;
566- double ck_cc [2 ];
567- double ck_cl [2 ];
568- double ck_cu [2 ];
569- double ck_rl [2 ];
570- double ck_ru [2 ];
571- HighsInt ck_a_start [3 ];
572- HighsInt ck_a_index [4 ];
573- double ck_a_value [4 ];
574561 HighsInt return_status ;
575- return_status = Highs_getModel (
576- highs , a_format , 0 , & ck_num_col , & ck_num_row , & ck_num_nz , NULL , & ck_sense ,
577- & ck_offset , ck_cc , ck_cl , ck_cu , ck_rl , ck_ru , ck_a_start , ck_a_index ,
578- ck_a_value , NULL , NULL , NULL , NULL );
579- assert (return_status == kHighsStatusOk );
580-
581- assert (ck_num_col == num_col );
582- assert (ck_num_row == num_row );
583- assert (ck_num_nz == num_nz );
584- assert (ck_sense == sense );
585- assert (ck_offset == offset );
586- assert (doubleArraysEqual (num_col , ck_cc , cc ));
587- assert (doubleArraysEqual (num_col , ck_cl , cl ));
588- assert (doubleArraysEqual (num_col , ck_cu , cu ));
589- assert (doubleArraysEqual (num_row , ck_rl , rl ));
590- assert (doubleArraysEqual (num_row , ck_ru , ru ));
591- assert (highsIntArraysEqual (num_col , ck_a_start , a_start ));
592- assert (highsIntArraysEqual (num_nz , ck_a_index , a_index ));
593- assert (doubleArraysEqual (num_nz , ck_a_value , a_value ));
594562
595- return_status = Highs_run (highs );
596- assert ( return_status == kHighsStatusOk );
563+ HighsInt num_col = Highs_getNumCols (highs );
564+ HighsInt num_row = Highs_getNumRows ( highs );
597565
598566 char * col_prefix = "Col" ;
599567 char * row_prefix = "Row" ;
600568 // Check index out of bounds
569+
601570 return_status = Highs_passColName (highs , -1 , col_prefix );
602571 assert (return_status == kHighsStatusError );
603572 return_status = Highs_passColName (highs , num_col , col_prefix );
@@ -1799,18 +1768,25 @@ void testGetModel() {
17991768 Highs_addRows (highs , num_row , row_lower , row_upper , num_nz , a_start , a_index ,
18001769 a_value );
18011770 Highs_changeObjectiveSense (highs , sense );
1802- Highs_run (highs );
1771+
1772+ assert (Highs_getNumCols (highs ) == num_col );
1773+ assert (Highs_getNumRows (highs ) == num_row );
1774+ assert (Highs_getNumNz (highs ) == num_nz );
1775+ assert (Highs_getHessianNumNz (highs ) == 0 );
18031776
18041777 HighsInt ck_num_col ;
18051778 HighsInt ck_num_row ;
18061779 HighsInt ck_num_nz ;
18071780 HighsInt ck_sense ;
18081781 double ck_offset ;
1782+ HighsInt a_format = kHighsMatrixFormatRowwise ;
18091783
18101784 // Get the model dimensions by passing array pointers as NULL
1811- Highs_getLp (highs , kHighsMatrixFormatRowwise , & ck_num_col , & ck_num_row ,
1785+ HighsInt return_status ;
1786+ return_status = Highs_getLp (highs , a_format , & ck_num_col , & ck_num_row ,
18121787 & ck_num_nz , & ck_sense , & ck_offset , NULL , NULL , NULL , NULL , NULL ,
18131788 NULL , NULL , NULL , NULL );
1789+ assert (return_status == kHighsStatusOk );
18141790
18151791 assert (ck_num_col == num_col );
18161792 assert (ck_num_row == num_row );
@@ -1829,11 +1805,32 @@ void testGetModel() {
18291805 double * ck_a_value = (double * )malloc (sizeof (double ) * num_nz );
18301806
18311807 // Get the arrays
1832- Highs_getLp (highs , kHighsMatrixFormatRowwise , & ck_num_col , & ck_num_row ,
1808+ return_status = Highs_getLp (highs , a_format , & ck_num_col , & ck_num_row ,
18331809 & ck_num_nz , & ck_sense , & ck_offset , ck_col_cost , ck_col_lower ,
18341810 ck_col_upper , ck_row_lower , ck_row_upper , ck_a_start , ck_a_index ,
18351811 ck_a_value , NULL );
1812+ assert (return_status == kHighsStatusOk );
1813+
1814+ assert (doubleArraysEqual (num_col , ck_col_cost , col_cost ));
1815+ assert (doubleArraysEqual (num_col , ck_col_lower , col_lower ));
1816+ assert (doubleArraysEqual (num_col , ck_col_upper , col_upper ));
1817+ assert (doubleArraysEqual (num_row , ck_row_lower , row_lower ));
1818+ assert (doubleArraysEqual (num_row , ck_row_upper , row_upper ));
1819+ assert (highsIntArraysEqual (num_col , ck_a_start , a_start ));
1820+ assert (highsIntArraysEqual (num_nz , ck_a_index , a_index ));
1821+ assert (doubleArraysEqual (num_nz , ck_a_value , a_value ));
18361822
1823+ return_status = Highs_getModel (
1824+ highs , a_format , 0 , & ck_num_col , & ck_num_row , & ck_num_nz , NULL , & ck_sense ,
1825+ & ck_offset , ck_col_cost , ck_col_lower ,
1826+ ck_col_upper , ck_row_lower , ck_row_upper , ck_a_start , ck_a_index ,
1827+ ck_a_value , NULL , NULL , NULL , NULL );
1828+ assert (return_status == kHighsStatusOk );
1829+
1830+ assert (ck_num_col == num_col );
1831+ assert (ck_num_row == num_row );
1832+ assert (ck_num_nz == num_nz );
1833+ assert (ck_sense == sense );
18371834 assert (doubleArraysEqual (num_col , ck_col_cost , col_cost ));
18381835 assert (doubleArraysEqual (num_col , ck_col_lower , col_lower ));
18391836 assert (doubleArraysEqual (num_col , ck_col_upper , col_upper ));
@@ -2455,30 +2452,30 @@ void testFixedLp() {
24552452}
24562453
24572454int main () {
2458- minimalApiIllegalLp ();
2459- testCallback ();
2460- versionApi ();
2461- fullApi ();
2462- minimalApiLp ();
2463- minimalApiMip ();
2464- minimalApiQp ();
2465- fullApiOptions ();
2466- fullApiLp ();
2467- fullApiMip ();
2468- fullApiQp ();
2469- passPresolveGetLp ();
2470- options ();
2471- testGetColsByRange ();
2472- testPassHessian ();
2473- testRanging ();
2474- testFeasibilityRelaxation ();
2475- testGetModel ();
2476- testMultiObjective ();
2477- testQpIndefiniteFailure ();
2478- testDualRayTwice ();
2479- testDeleteRowResolveWithBasis ();
2480- testIis ();
2481- testFixedLp ();
2455+ // minimalApiIllegalLp();
2456+ // testCallback();
2457+ // versionApi();
2458+ // minimalApiLp ();
2459+ // minimalApiMip ();
2460+ // minimalApiQp ();
2461+ // fullApiOptions ();
2462+ // fullApiLp ();
2463+ // fullApiMip ();
2464+ // fullApiQp ();
2465+ // passPresolveGetLp ();
2466+ // options ();
2467+ // testGetColsByRange ();
2468+ // testPassHessian ();
2469+ // testRanging ();
2470+ // testFeasibilityRelaxation ();
2471+ testNames ();
2472+ // testGetModel();
2473+ // testMultiObjective();
2474+ // testQpIndefiniteFailure();
2475+ // testDualRayTwice();
2476+ // testDeleteRowResolveWithBasis();
2477+ // testIis();
2478+ // testFixedLp();
24822479 return 0 ;
24832480}
24842481// testSetSolution();
0 commit comments