@@ -699,3 +699,42 @@ void runSetLpSolution(const std::string model) {
699699
700700 highs.resetGlobalScheduler (true );
701701}
702+
703+ TEST_CASE (" miplib-sol-file" , " [highs_filereader]" ) {
704+ const std::string test_name = Catch::getResultCapture ().getCurrentTestName ();
705+ std::string sol_file = test_name + " .sol" ;
706+ std::string lp_file = test_name + " .lp" ;
707+ FILE* file = fopen (lp_file.c_str (), " w" );
708+ std::string file_content =
709+ " Minimize\n obj: 2 sel_2 + sel_3\n Subject To\n r0: sel_0 - sel_1 + sel_4 "
710+ " >= "
711+ " 2\n End\n " ;
712+ if (dev_run) printf (" Using .lp file\n %s" , file_content.c_str ());
713+ fprintf (file, " %s" , file_content.c_str ());
714+ fclose (file);
715+ Highs h;
716+ h.setOptionValue (" output_flag" , dev_run);
717+ REQUIRE (h.readModel (lp_file) == HighsStatus::kOk );
718+
719+ file = fopen (sol_file.c_str (), " w" );
720+ file_content =
721+ " =obj= 203672547.1\n sel_0 1\n sel_1 0\n sel_2 0\n sel_3 0\n sel_4 1\n " ;
722+ if (dev_run) printf (" Using .sol file\n %s" , file_content.c_str ());
723+ fprintf (file, " %s" , file_content.c_str ());
724+ fclose (file);
725+ REQUIRE (h.readSolution (sol_file) == HighsStatus::kOk );
726+
727+ std::vector<double > solution = h.getSolution ().col_value ;
728+ REQUIRE (solution[0 ] == 0 );
729+ REQUIRE (solution[1 ] == 0 );
730+ REQUIRE (solution[2 ] == 1 );
731+ REQUIRE (solution[3 ] == 0 );
732+ REQUIRE (solution[4 ] == 1 );
733+
734+ REQUIRE (h.run () == HighsStatus::kOk );
735+
736+ std::remove (lp_file.c_str ());
737+ std::remove (sol_file.c_str ());
738+
739+ h.resetGlobalScheduler (true );
740+ }
0 commit comments