@@ -3524,3 +3524,113 @@ void getSubVectorsTranspose(const HighsIndexCollection& index_collection,
35243524 }
35253525 }
35263526}
3527+
3528+ void initialiseUserScaleData (const HighsOptions& options,
3529+ HighsUserScaleData& user_scale_data) {
3530+ user_scale_data.initialise (options.user_objective_scale ,
3531+ options.user_bound_scale , options.infinite_cost ,
3532+ options.infinite_bound , options.small_matrix_value ,
3533+ options.large_matrix_value );
3534+ }
3535+
3536+ void HighsUserScaleData::initialise (const HighsInt& user_objective_scale_,
3537+ const HighsInt& user_bound_scale_,
3538+ const double & infinite_cost_,
3539+ const double & infinite_bound_,
3540+ const double & small_matrix_value_,
3541+ const double & large_matrix_value_) {
3542+ this ->user_objective_scale = user_objective_scale_;
3543+ this ->user_bound_scale = user_bound_scale_;
3544+ this ->infinite_cost = infinite_cost_;
3545+ this ->infinite_bound = infinite_bound_;
3546+ this ->small_matrix_value = small_matrix_value_;
3547+ this ->large_matrix_value = large_matrix_value_;
3548+ this ->num_infinite_costs = 0 ;
3549+ this ->num_infinite_hessian_values = 0 ;
3550+ this ->num_infinite_col_bounds = 0 ;
3551+ this ->num_infinite_row_bounds = 0 ;
3552+ this ->num_small_matrix_values = 0 ;
3553+ this ->num_large_matrix_values = 0 ;
3554+ this ->suggested_user_objective_scale = 0 ;
3555+ this ->suggested_user_bound_scale = 0 ;
3556+ this ->applied = false ;
3557+ }
3558+
3559+ bool HighsUserScaleData::scaleError (std::string& message) const {
3560+ if (this ->num_infinite_costs + this ->num_infinite_hessian_values +
3561+ this ->num_infinite_col_bounds + this ->num_infinite_row_bounds +
3562+ this ->num_large_matrix_values ==
3563+ 0 )
3564+ return false ;
3565+ assert (this ->user_objective_scale != 0 || this ->user_bound_scale != 0 );
3566+ std::stringstream ss;
3567+ ss.str (std::string ());
3568+ ss << " User scaling of" ;
3569+ if (this ->user_objective_scale != 0 ) {
3570+ ss << " 2**(" << this ->user_objective_scale << " ) for costs" ;
3571+ }
3572+ if (this ->user_bound_scale != 0 ) {
3573+ if (this ->user_objective_scale != 0 ) ss << " and" ;
3574+ ss << " 2**(" << this ->user_bound_scale << " ) for bounds" ;
3575+ }
3576+ ss << " yields" ;
3577+ if (this ->num_infinite_costs ) {
3578+ ss << " " << this ->num_infinite_costs << " infinite cost" ;
3579+ if (this ->num_infinite_costs > 1 ) ss << " s" ;
3580+ }
3581+ if (this ->num_infinite_hessian_values ) {
3582+ if (this ->num_infinite_costs ) {
3583+ if (this ->num_infinite_col_bounds || this ->num_infinite_row_bounds ) {
3584+ ss << " ," ;
3585+ } else {
3586+ ss << " and" ;
3587+ }
3588+ }
3589+ ss << " " << this ->num_infinite_hessian_values
3590+ << " infinite Hessian values" ;
3591+ if (this ->num_infinite_hessian_values > 1 ) ss << " s" ;
3592+ }
3593+ if (this ->num_infinite_col_bounds ) {
3594+ if (this ->num_infinite_costs || this ->num_infinite_hessian_values ) {
3595+ if (this ->num_infinite_row_bounds ) {
3596+ ss << " ," ;
3597+ } else {
3598+ ss << " and" ;
3599+ }
3600+ }
3601+ ss << " " << this ->num_infinite_col_bounds << " infinite column bound" ;
3602+ if (this ->num_infinite_col_bounds > 1 ) ss << " s" ;
3603+ }
3604+ if (this ->num_infinite_row_bounds ) {
3605+ if (this ->num_infinite_costs || this ->num_infinite_hessian_values ||
3606+ this ->num_infinite_col_bounds )
3607+ ss << " and" ;
3608+ ss << " " << this ->num_infinite_row_bounds << " infinite row bound" ;
3609+ if (this ->num_infinite_row_bounds > 1 ) ss << " s" ;
3610+ }
3611+ if (this ->num_large_matrix_values ) {
3612+ if (this ->num_infinite_costs + this ->num_infinite_hessian_values +
3613+ this ->num_infinite_col_bounds + this ->num_infinite_row_bounds >
3614+ 0 )
3615+ ss << " , and" ;
3616+ ss << " " << this ->num_large_matrix_values << " large matrix value" ;
3617+ if (this ->num_large_matrix_values > 1 ) ss << " s" ;
3618+ }
3619+ ss << " \n " ;
3620+ message = ss.str ();
3621+ return true ;
3622+ }
3623+
3624+ bool HighsUserScaleData::scaleWarning (std::string& message) const {
3625+ if (this ->num_small_matrix_values == 0 ) return false ;
3626+ assert (this ->user_bound_scale != 0 );
3627+ std::stringstream ss;
3628+ ss.str (std::string ());
3629+ ss << " User scaling of 2**(" << this ->user_bound_scale
3630+ << " ) for bounds yields " << this ->num_small_matrix_values
3631+ << " small matrix value" ;
3632+ if (this ->num_small_matrix_values > 1 ) ss << " s" ;
3633+ ss << " \n " ;
3634+ message = ss.str ();
3635+ return true ;
3636+ }
0 commit comments