74 hint_proto: model_parameters_pb2.SolutionHintProto, mod:
model.Model
76 """Returns an equivalent SolutionHint to `hint_proto`.
79 hint_proto: The solution, as encoded by the ids of the variables and
81 mod: A MathOpt Model that must contain variables and linear constraints with
82 the ids from hint_proto.
85 A SolutionHint equivalent.
88 ValueError if hint_proto is invalid or refers to variables or constraints
92 variable_values=sparse_containers.parse_variable_map(
93 hint_proto.variable_values, mod
95 dual_values=sparse_containers.parse_linear_constraint_map(
96 hint_proto.dual_values, mod
101@dataclasses.dataclass
103 """Model specific solver configuration, for example, an initial basis.
105 This class mirrors (and can generate) the related proto
106 model_parameters_pb2.ModelSolveParametersProto.
109 variable_values_filter: Only return solution and primal ray values for
110 variables accepted by this filter (default accepts all variables).
111 dual_values_filter: Only return dual variable values and dual ray values for
112 linear constraints accepted by thei filter (default accepts all linear
114 reduced_costs_filter: Only return reduced cost and dual ray values for
115 variables accepted by this filter (default accepts all variables).
116 initial_basis: If set, provides a warm start for simplex based solvers.
117 solution_hints: Optional solution hints. If the underlying solver only
118 accepts a single hint, the first hint is used.
119 branching_priorities: Optional branching priorities. Variables with higher
120 values will be branched on first. Variables for which priorities are not
121 set get the solver's default priority (usually zero).
124 variable_values_filter: sparse_containers.VariableFilter = (
125 sparse_containers.VariableFilter()
127 dual_values_filter: sparse_containers.LinearConstraintFilter = (
128 sparse_containers.LinearConstraintFilter()
130 reduced_costs_filter: sparse_containers.VariableFilter = (
131 sparse_containers.VariableFilter()
134 solution_hints: List[SolutionHint] = dataclasses.field(default_factory=list)
139 def to_proto(self) -> model_parameters_pb2.ModelSolveParametersProto:
140 """Returns an equivalent protocol buffer."""
143 result = model_parameters_pb2.ModelSolveParametersProto(
147 branching_priorities=sparse_containers.to_sparse_int32_vector_proto(
154 result.solution_hints.append(hint.to_proto())