Пример #1
0
    def _process_rhs(self, data_line: DataLine):
        if len(self._rhs) != len(self.constraint_names):
            self._rhs = np.zeros(len(self.constraint_names))

        self._add_rhs(data_line.second_name(), data_line.first_number())

        if data_line.has_third_name() and data_line.has_second_number():
            self._add_rhs(data_line.third_name(), data_line.second_number())
Пример #2
0
def test_third_name_columns(line, expected):
    """
    The third name field is the 40-47 column range (inclusive).
    """
    padding = " " * 39  # starts at column 40, so 39 spaces.
    data_line = DataLine(padding + line)

    assert_equal(data_line.third_name(), expected)
Пример #3
0
    def _process_scenarios(self, data_line: DataLine):
        if data_line.indicator() == "SC":  # new scenario
            scen = Scenario(data_line.first_name(), data_line.second_name(),
                            data_line.third_name(), data_line.first_number())

            self._current_scen = scen
            return

        var = data_line.first_name()
        constr = data_line.second_name()
        value = data_line.first_number()

        assert self._current_scen is not None
        self._current_scen.add_modification(constr, var, value)

        if data_line.has_third_name() and data_line.has_second_number():
            constr = data_line.third_name()
            value = data_line.second_number()

            self._current_scen.add_modification(constr, var, value)
Пример #4
0
    def _process_periods(self, data_line: DataLine):
        assert data_line.has_third_name()

        period = data_line.third_name()
        self._stage_names.append(period)

        if self._param == "IMPLICIT":
            # In the IMPLICIT formulation, the PERIODS section also contains
            # the (var, constr) offsets of this stage's CORE data.
            var = data_line.first_name()
            constr = data_line.second_name()

            self._stage_offsets.append((var, constr))
Пример #5
0
    def _parse_marker(self, data_line: DataLine):
        assert data_line.has_third_name()

        name = data_line.first_name()
        marker_type = data_line.third_name()

        logger.debug(f"Encountered a {marker_type} marker named {name}.")

        if "INTORG" in marker_type.upper():
            self._parse_ints = True

        if "INTEND" in marker_type.upper():
            self._parse_ints = False
Пример #6
0
    def _parse_column(self, data_line: DataLine):
        var = data_line.first_name()

        if var not in self._var2idx:
            self._variable_names.append(var)
            self._types.append('I' if self._parse_ints else 'C')
            self._var2idx[var] = len(self._variable_names) - 1

        constr = data_line.second_name()
        value = data_line.first_number()
        self._add_value(constr, var, value)

        if data_line.has_third_name() and data_line.has_second_number():
            constr = data_line.third_name()
            value = data_line.second_number()
            self._add_value(constr, var, value)