@@ -315,3 +315,43 @@ void testBasisRestart(Highs& highs, const std::string& basis_file,
315315
316316 REQUIRE (info.simplex_iteration_count == 0 );
317317}
318+
319+ TEST_CASE (" Basis-read" , " [highs_basis_data]" ) {
320+ // Duplicates test_read_basis in test_highspy.py
321+ const std::string test_name = Catch::getResultCapture ().getCurrentTestName ();
322+
323+ HighsLp lp;
324+ lp.num_col_ = 2 ;
325+ lp.num_row_ = 2 ;
326+ lp.col_cost_ = {0 , 1 };
327+ lp.col_lower_ .assign (lp.num_col_ , -kHighsInf );
328+ lp.col_upper_ .assign (lp.num_col_ , kHighsInf );
329+ lp.row_lower_ = {2 , 0 };
330+ lp.row_upper_ .assign (lp.num_row_ , kHighsInf );
331+ lp.a_matrix_ .start_ = {0 , 2 , 4 };
332+ lp.a_matrix_ .index_ = {0 , 1 , 0 , 1 };
333+ lp.a_matrix_ .value_ = {-1 , 1 , 1 , 1 };
334+
335+ HighsBasisStatus status_before = HighsBasisStatus::kNonbasic ;
336+ HighsBasisStatus status_after = HighsBasisStatus::kBasic ;
337+ Highs h1;
338+ const HighsBasis& basis1 = h1.getBasis ();
339+ h1.passModel (lp);
340+ REQUIRE (basis1.col_status [0 ] == status_before);
341+ h1.run ();
342+ REQUIRE (basis1.col_status [0 ] == status_after);
343+
344+ Highs h2;
345+ const HighsBasis& basis2 = h2.getBasis ();
346+ h2.passModel (lp);
347+ REQUIRE (basis2.col_status [0 ] == status_before);
348+
349+ const std::string basis_file = test_name + " .bas" ;
350+ h1.writeBasis (basis_file);
351+ h2.readBasis (basis_file);
352+ REQUIRE (basis2.col_status [0 ] == status_after);
353+
354+ std::remove (basis_file.c_str ());
355+ h1.resetGlobalScheduler (true );
356+ h2.resetGlobalScheduler (true );
357+ }
0 commit comments