@@ -769,86 +769,22 @@ HighsStatus cleanBounds(const HighsOptions& options, HighsLp& lp) {
769769 return HighsStatus::kOk ;
770770}
771771
772- HighsStatus userScaleLp (const vector<HighsVarType>& integrality,
773- vector<double >& cost, vector<double >& col_lower,
774- vector<double >& col_upper, vector<double >& row_lower,
775- vector<double >& row_upper, HighsSparseMatrix& matrix,
772+ HighsStatus userScaleLp (HighsLp& lp,
776773 HighsUserScaleData& data,
777774 const HighsLogOptions& log_options) {
778- userScaleLp (integrality, cost, col_lower, col_upper, row_lower, row_upper,
779- matrix, data, false );
775+ userScaleLp (lp, data, false );
780776 HighsStatus return_status = userScaleStatus (log_options, data);
781777 if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
782- userScaleLp (integrality, cost, col_lower, col_upper, row_lower, row_upper,
783- matrix, data);
778+ userScaleLp (lp, data);
784779 return return_status;
785780}
786781
787- void userScaleLp (const vector<HighsVarType>& integrality, vector<double >& cost,
788- vector<double >& col_lower, vector<double >& col_upper,
789- vector<double >& row_lower, vector<double >& row_upper,
790- HighsSparseMatrix& matrix, HighsUserScaleData& data,
782+ void userScaleLp (HighsLp& lp, HighsUserScaleData& data,
791783 const bool apply) {
792- userScaleCosts (integrality, cost, data, apply);
793- userScaleColBounds (integrality, col_lower, col_upper, data, apply);
794- userScaleMatrix (integrality, matrix, data, apply);
795- userScaleRowBounds (row_lower, row_upper, data, apply);
796- }
797-
798- // To check/apply user scaling to data for columns - used in
799- // Highs::addColsInterface
800- HighsStatus userScaleNewCols (vector<double >& cost, vector<double >& lower,
801- vector<double >& upper, HighsSparseMatrix& matrix,
802- HighsUserScaleData& data,
803- const HighsLogOptions& log_options) {
804- userScaleNewCols (cost, lower, upper, matrix, data, false );
805- HighsStatus return_status = userScaleStatus (log_options, data);
806- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
807- userScaleNewCols (cost, lower, upper, matrix, data);
808- return return_status;
809- }
810-
811- void userScaleNewCols (vector<double >& cost, vector<double >& lower,
812- vector<double >& upper, HighsSparseMatrix& matrix,
813- HighsUserScaleData& data, const bool apply) {
814- // Set up a dummy integrality vector since there's not yet any
815- // integrality for these columns
816- vector<HighsVarType> integrality;
817- userScaleCosts (integrality, cost, data, apply);
818- userScaleColBounds (integrality, lower, upper, data, apply);
819- userScaleMatrix (integrality, matrix, data, apply);
820- }
821-
822- // To check/apply user scaling to data for rows - used in
823- // Highs::addRowsInterface
824- HighsStatus userScaleNewRows (const vector<HighsVarType>& integrality,
825- vector<double >& lower, vector<double >& upper,
826- HighsSparseMatrix& matrix,
827- HighsUserScaleData& data,
828- const HighsLogOptions& log_options) {
829- userScaleNewRows (integrality, lower, upper, matrix, data, false );
830- HighsStatus return_status = userScaleStatus (log_options, data);
831- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
832- userScaleNewRows (integrality, lower, upper, matrix, data);
833- return return_status;
834- }
835-
836- void userScaleNewRows (const vector<HighsVarType>& integrality,
837- vector<double >& lower, vector<double >& upper,
838- HighsSparseMatrix& matrix, HighsUserScaleData& data,
839- const bool apply) {
840- userScaleRowBounds (lower, upper, data, apply);
841- userScaleMatrix (integrality, matrix, data, apply);
842- }
843-
844- HighsStatus userScaleCosts (const vector<HighsVarType>& integrality,
845- vector<double >& cost, HighsUserScaleData& data,
846- const HighsLogOptions& log_options) {
847- userScaleCosts (integrality, cost, data, false );
848- HighsStatus return_status = userScaleStatus (log_options, data);
849- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
850- userScaleCosts (integrality, cost, data);
851- return return_status;
784+ userScaleCosts (lp.integrality_ , lp.col_cost_ , data, apply);
785+ userScaleColBounds (lp.integrality_ , lp.col_lower_ , lp.col_upper_ , data, apply);
786+ userScaleMatrix (lp.integrality_ , lp.a_matrix_ , data, apply);
787+ userScaleRowBounds (lp.row_lower_ , lp.row_upper_ , data, apply);
852788}
853789
854790void userScaleCosts (const vector<HighsVarType>& integrality,
@@ -875,17 +811,6 @@ void userScaleCosts(const vector<HighsVarType>& integrality,
875811 }
876812}
877813
878- HighsStatus userScaleColBounds (const vector<HighsVarType>& integrality,
879- vector<double >& lower, vector<double >& upper,
880- HighsUserScaleData& data,
881- const HighsLogOptions& log_options) {
882- userScaleColBounds (integrality, lower, upper, data, false );
883- HighsStatus return_status = userScaleStatus (log_options, data);
884- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
885- userScaleColBounds (integrality, lower, upper, data);
886- return return_status;
887- }
888-
889814void userScaleColBounds (const vector<HighsVarType>& integrality,
890815 vector<double >& lower, vector<double >& upper,
891816 HighsUserScaleData& data, const bool apply) {
@@ -916,16 +841,6 @@ void userScaleColBounds(const vector<HighsVarType>& integrality,
916841 }
917842}
918843
919- HighsStatus userScaleRowBounds (vector<double >& lower, vector<double >& upper,
920- HighsUserScaleData& data,
921- const HighsLogOptions& log_options) {
922- userScaleRowBounds (lower, upper, data, false );
923- HighsStatus return_status = userScaleStatus (log_options, data);
924- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
925- userScaleRowBounds (lower, upper, data);
926- return return_status;
927- }
928-
929844void userScaleRowBounds (vector<double >& lower, vector<double >& upper,
930845 HighsUserScaleData& data, const bool apply) {
931846 data.num_infinite_row_bounds = 0 ;
@@ -948,16 +863,6 @@ void userScaleRowBounds(vector<double>& lower, vector<double>& upper,
948863 }
949864}
950865
951- HighsStatus userScaleMatrix (const vector<HighsVarType>& integrality,
952- HighsSparseMatrix& matrix, HighsUserScaleData& data,
953- const HighsLogOptions& log_options) {
954- userScaleMatrix (integrality, matrix, data, false );
955- HighsStatus return_status = userScaleStatus (log_options, data);
956- if (return_status == HighsStatus::kError ) return HighsStatus::kError ;
957- userScaleMatrix (integrality, matrix, data);
958- return return_status;
959- }
960-
961866void userScaleMatrix (const vector<HighsVarType>& integrality,
962867 HighsSparseMatrix& matrix, HighsUserScaleData& data,
963868 const bool apply) {
@@ -1837,23 +1742,22 @@ HighsStatus changeLpIntegrality(HighsLp& lp,
18371742 // - which are naturally continuous
18381743 lp.integrality_ .assign (lp.num_col_ , HighsVarType::kContinuous );
18391744 } else if (lp.user_bound_scale_ ) {
1745+ // Save a copy of lp.integrality_ in case it needs to be reverted
1746+ // due to ultimate illegal scaling
1747+ save_integrality = lp.integrality_ ;
18401748 // Revert the user bound scaling to correspond to an LP...
18411749 //
1842- // Unscale the costs and matrix columns, and the
1843- // continuous bounds, by scaling with -lp.user_bound_scale_
1750+ // Use -lp.user_bound_scale_U to unscale the costs and matrix
1751+ // columns, and the continuous bounds
18441752 //
18451753 // Set up HighsUserScaleData, noting that any user cost scaling is
18461754 // unaffected
18471755 initialiseUserScaleData (lp, options, user_scale_data);
18481756 user_scale_data.user_cost_scale = 0 ;
18491757 user_scale_data.user_bound_scale = -lp.user_bound_scale_ ;
1850- userScaleCosts (lp.integrality_ , lp.col_cost_ , user_scale_data);
1851- userScaleColBounds (lp.integrality_ , lp.col_lower_ , lp.col_upper_ ,
1852- user_scale_data);
1853- userScaleMatrix (lp.integrality_ , lp.a_matrix_ , user_scale_data);
1854- // Save a copy of lp.integrality_ in case it needs to be reverted
1855- // due to ultimate illegal scaling
1856- save_integrality = lp.integrality_ ;
1758+ // Scale, forcing changes of value
1759+ const bool apply = true ;
1760+ userScaleLp (lp, user_scale_data, apply);
18571761 }
18581762
18591763 assert (HighsInt (lp.integrality_ .size ()) == lp.num_col_ );
@@ -1879,16 +1783,14 @@ HighsStatus changeLpIntegrality(HighsLp& lp,
18791783 } else if (lp.user_bound_scale_ ) {
18801784 // ... and then reapply corresponding to the new integrality
18811785 //
1882- // Scale the costs and matrix columns, and the continuous bounds ,
1883- // by scaling with lp.user_bound_scale_
1786+ // Use lp.user_bound_scale_ to scale the costs and matrix columns,
1787+ // and the continuous bounds
18841788 user_scale_data.user_bound_scale = lp.user_bound_scale_ ;
1885- userScaleCosts (lp.integrality_ , lp.col_cost_ , user_scale_data,
1886- options.log_options );
1887- userScaleColBounds (lp.integrality_ , lp.col_lower_ , lp.col_upper_ ,
1888- user_scale_data, options.log_options );
1889- userScaleMatrix (lp.integrality_ , lp.a_matrix_ , user_scale_data,
1890- options.log_options );
1891- if (user_scale_data.scaleError ()) {
1789+
1790+ // Scale, first checking and reporting illegal values, then
1791+ // forcing changes of value if no illegal values
1792+ return_status = userScaleLp (lp, user_scale_data, options.log_options );
1793+ if (return_status == HighsStatus::kError ) {
18921794 lp.integrality_ = save_integrality;
18931795 return HighsStatus::kError ;
18941796 }
0 commit comments