@@ -363,7 +363,31 @@ int SRSsetcoefs(SRS_PROBLEM * problem_srs,
363363 return 0 ;
364364}
365365
366- int allocateProblemsAndPropagateParams (SRS_PROBLEM * problem_srs ) {
366+ void setStartingBasis (PROBLEME_SIMPLEXE * problem_simplexe , const int * column_basis_status , const int * row_basis_status )
367+ {
368+ if (column_basis_status == NULL || row_basis_status == NULL )
369+ {
370+ return ;
371+ }
372+ problem_simplexe -> BaseDeDepartFournie = OUI_SPX ;
373+ // Column basis
374+ for (int i = 0 ; i < problem_simplexe -> NombreDeVariables ; ++ i )
375+ {
376+ problem_simplexe -> PositionDeLaVariable [i ] = column_basis_status [i ];
377+ }
378+ // Slack variables basis
379+ problem_simplexe -> NbVarDeBaseComplementaires = 0 ;
380+ for (int i = 0 ; i < problem_simplexe -> NombreDeContraintes ; ++ i )
381+ {
382+ if (row_basis_status [i ] == EN_BASE )
383+ {
384+ problem_simplexe -> ComplementDeLaBase [problem_simplexe -> NbVarDeBaseComplementaires ] = i ;
385+ problem_simplexe -> NbVarDeBaseComplementaires ++ ;
386+ }
387+ }
388+ }
389+
390+ int allocateProblemsAndPropagateParams (SRS_PROBLEM * problem_srs , const int * column_basis_status , const int * row_basis_status ) {
367391 if (problem_srs -> is_mip ) {
368392 problem_srs -> problem_mip = malloc (sizeof (PROBLEME_A_RESOUDRE ));
369393 PNE_copy_problem (problem_srs -> problem_mps , problem_srs -> problem_mip , 0 , 0.0 );
@@ -428,22 +452,28 @@ int allocateProblemsAndPropagateParams(SRS_PROBLEM * problem_srs) {
428452
429453 problem_simplexe -> CoutMax = 0 ;
430454 problem_simplexe -> NbVarDeBaseComplementaires = 0 ;
455+
456+ setStartingBasis (problem_simplexe , column_basis_status , row_basis_status );
431457 }
432458
433459 return 0 ;
434460}
435461
462+ int SRSoptimize (SRS_PROBLEM * problem_srs )
463+ {
464+ return SRSoptimizewithinitialbasis (problem_srs , NULL , NULL );
465+ }
466+
467+ int SRSoptimizewithinitialbasis (SRS_PROBLEM * problem_srs , const int * column_basis_status , const int * row_basis_status ) {
436468
437- int SRSoptimize (SRS_PROBLEM * problem_srs ) {
438-
439469 int nbCols = problem_srs -> problem_mps -> NbVar ;
440470 if (problem_srs -> maximize ) {
441471 for (int idxCol = 0 ; idxCol < nbCols ; ++ idxCol ) {
442472 problem_srs -> problem_mps -> L [idxCol ] *= -1.0 ;
443473 }
444474 }
445-
446- allocateProblemsAndPropagateParams (problem_srs );
475+
476+ allocateProblemsAndPropagateParams (problem_srs , column_basis_status , row_basis_status );
447477
448478 struct timespec debut ;
449479 timespec_get (& debut , TIME_UTC );
@@ -702,7 +732,7 @@ int SRSsetintparams(SRS_PROBLEM * problem_srs, const char * paramId, int paramVa
702732 return -1 ;
703733}
704734
705- int SRSsetdoubleparams (SRS_PROBLEM * problem_srs , const char * paramId , double paramValue ) {
735+ int SRSsetdoubleparams (SRS_PROBLEM * problem_srs , const char * paramId , double paramValue ) {
706736 if (strcmp (SRS_PARAM_RELATIVE_GAP , paramId ) == 0 ) {
707737 problem_srs -> relativeGap = paramValue ;
708738 return 0 ;
@@ -779,12 +809,9 @@ int SRSgetrowbasisstatus(SRS_PROBLEM * problem_srs, char ** rowStatuses) {
779809 }
780810
781811 int nbRow = problem_srs -> problem_mps -> NbCnt ;
782- (* rowStatuses ) = malloc (nbRow * sizeof (char ));
783-
784812 for (int idx = 0 ; idx < nbRow ; ++ idx ) {
785813 (* rowStatuses )[idx ] = EN_BASE_LIBRE ;
786814 }
787-
788815 for (int idx = 0 ; idx < problem_srs -> problem_simplexe -> NbVarDeBaseComplementaires ; ++ idx )
789816 {
790817 (* rowStatuses )[problem_srs -> problem_simplexe -> ComplementDeLaBase [idx ]] = EN_BASE ;
0 commit comments