Пример #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_second_number_columns(line, expected):
    """
    The second numeric field is the 50-61 column range (inclusive).
    """
    padding = " " * 49  # starts at column 50, so 49 spaces.
    data_line = DataLine(padding + line)

    assert_almost_equal(data_line.second_number(), expected)
Пример #3
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)
Пример #4
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)