16#include "absl/log/check.h"
17#include "ortools/linear_solver/linear_solver.pb.h"
28 MPModelProto* output) {
30 output->set_name(
input.name());
31 output->set_maximize(
input.IsMaximizationProblem());
32 output->set_objective_offset(
input.objective_offset());
34 MPVariableProto* variable = output->add_variable();
35 variable->set_lower_bound(
input.variable_lower_bounds()[
col]);
36 variable->set_upper_bound(
input.variable_upper_bounds()[
col]);
37 variable->set_name(
input.GetVariableName(
col));
38 variable->set_is_integer(
input.IsVariableInteger(
col));
39 variable->set_objective_coefficient(
input.objective_coefficients()[
col]);
46 MPConstraintProto* constraint = output->add_constraint();
47 constraint->set_lower_bound(
input.constraint_lower_bounds()[
row]);
48 constraint->set_upper_bound(
input.constraint_upper_bounds()[
row]);
49 constraint->set_name(
input.GetConstraintName(
row));
51 constraint->add_var_index(e.row().value());
52 constraint->add_coefficient(e.coefficient());
65 for (
int i = 0; i <
input.variable_size(); ++i) {
66 const MPVariableProto&
var =
input.variable(i);
71 if (
var.is_integer()) {
75 for (
int j = 0; j <
input.constraint_size(); ++j) {
76 const MPConstraintProto& cst =
input.constraint(j);
82 CHECK_EQ(cst.var_index_size(), cst.coefficient_size());
83 for (
int k = 0; k < cst.var_index_size(); ++k) {
void SetName(absl::string_view name)
Name setter and getter.
void Clear()
Clears, i.e. reset the object to its initial value.
void SetConstraintName(RowIndex row, absl::string_view name)
@ INTEGER
The variable must only take integer values.
void SetObjectiveOffset(Fractional objective_offset)
void SetObjectiveCoefficient(ColIndex col, Fractional value)
void SetVariableBounds(ColIndex col, Fractional lower_bound, Fractional upper_bound)
void SetVariableType(ColIndex col, VariableType type)
Set the type of the variable.
void SetConstraintBounds(RowIndex row, Fractional lower_bound, Fractional upper_bound)
void SetCoefficient(RowIndex row, ColIndex col, Fractional value)
Defines the coefficient for col / row.
void SetVariableName(ColIndex col, absl::string_view name)
RowIndex CreateNewConstraint()
ColIndex CreateNewVariable()
void SetMaximizationProblem(bool maximize)
const SparseColumn & column(ColIndex col) const
Access the underlying sparse columns.
void PopulateFromTranspose(const Matrix &input)
Instantiate needed templates.
void LinearProgramToMPModelProto(const LinearProgram &input, MPModelProto *output)
Converts a LinearProgram to a MPModelProto.
ColIndex RowToColIndex(RowIndex row)
Get the ColIndex corresponding to the column # row.
void MPModelProtoToLinearProgram(const MPModelProto &input, LinearProgram *output)
Converts a MPModelProto to a LinearProgram.
In SWIG mode, we don't want anything besides these top-level includes.
static int input(yyscan_t yyscanner)