MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / passLocalOptions

Function passLocalOptions

highs/lp_data/HighsOptions.cpp:740–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740OptionStatus passLocalOptions(const HighsLogOptions& report_log_options,
741 const HighsOptions& from_options,
742 HighsOptions& to_options) {
743 // (Attempt to) set option value from the HighsOptions passed in
744 OptionStatus return_status;
745 // std::string empty_file = "";
746 // std::string from_log_file = from_options.log_file;
747 // std::string original_to_log_file = to_options.log_file;
748 // FILE* original_to_log_stream =
749 // to_options.log_options.log_stream;
750 HighsInt num_options = to_options.records.size();
751 // Check all the option values before setting any of them - in case
752 // to_options are the main Highs options. Checks are only needed for
753 // HighsInt, double and string since bool values can't be illegal
754 for (HighsInt index = 0; index < num_options; index++) {
755 HighsOptionType type = to_options.records[index]->type;
756 if (type == HighsOptionType::kInt) {
757 HighsInt value =
758 *(((OptionRecordInt*)from_options.records[index])[0].value);
759 return_status = checkOptionValue(
760 report_log_options, ((OptionRecordInt*)to_options.records[index])[0],
761 value);
762 if (return_status != OptionStatus::kOk) return return_status;
763 } else if (type == HighsOptionType::kDouble) {
764 double value =
765 *(((OptionRecordDouble*)from_options.records[index])[0].value);
766 return_status = checkOptionValue(
767 report_log_options,
768 ((OptionRecordDouble*)to_options.records[index])[0], value);
769 if (return_status != OptionStatus::kOk) return return_status;
770 } else if (type == HighsOptionType::kString) {
771 std::string value =
772 *(((OptionRecordString*)from_options.records[index])[0].value);
773 return_status = checkOptionValue(
774 report_log_options,
775 ((OptionRecordString*)to_options.records[index])[0], value);
776 if (return_status != OptionStatus::kOk) return return_status;
777 }
778 }
779 // Checked from_options and found it to be OK, so set all the values
780 for (HighsInt index = 0; index < num_options; index++) {
781 HighsOptionType type = to_options.records[index]->type;
782 if (type == HighsOptionType::kBool) {
783 bool value = *(((OptionRecordBool*)from_options.records[index])[0].value);
784 return_status = setLocalOptionValue(
785 ((OptionRecordBool*)to_options.records[index])[0], value);
786 if (return_status != OptionStatus::kOk) return return_status;
787 } else if (type == HighsOptionType::kInt) {
788 HighsInt value =
789 *(((OptionRecordInt*)from_options.records[index])[0].value);
790 return_status = setLocalOptionValue(
791 report_log_options, ((OptionRecordInt*)to_options.records[index])[0],
792 value);
793 if (return_status != OptionStatus::kOk) return return_status;
794 } else if (type == HighsOptionType::kDouble) {
795 double value =
796 *(((OptionRecordDouble*)from_options.records[index])[0].value);
797 return_status = setLocalOptionValue(

Callers 1

passOptionsMethod · 0.85

Calls 3

checkOptionValueFunction · 0.85
setLocalOptionValueFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected