special_ordered_set_type_1
relationalai.semantics.reasoners.prescriptive.problem
special_ordered_set_type_1(index: Any, variables: Any) -> b.AggregateReturn an SOS1 constraint (at most one variable is non-zero).
Use this inside Model.require and
pass the resulting fragment to Problem.satisfy.
Arguments must reference decision variables declared via
Problem.solve_for.
Commonly used for piecewise-linear formulations.
Parameters
Section titled “Parameters”
(indexAny) - Ordering index used to define the set.
(variablesAny) - Decision-variable expression(s) in the SOS1 set.
Returns
Section titled “Returns”Aggregate- A solver aggregate representing the SOS1 constraint.
Examples
Section titled “Examples”Create nonnegative weights and constrain them with SOS1:
>>> from relationalai.semantics import Float, Integer, Model, std>>> from relationalai.semantics.reasoners.prescriptive import Problem, special_ordered_set_type_1>>> m = Model("sos1_demo")>>> Point = m.Concept("Point", identify_by={"i": Integer})>>> Point.w = m.Property(f"{Point} has {Float:w}")>>> m.define(Point.new(i=std.common.range(3)))>>> p = Problem(m, Float)>>> p.solve_for(Point.w, name=["w", Point.i], lower=0)>>> p.satisfy(m.require(special_ordered_set_type_1(Point.i, Point.w)))Referenced By
Section titled “Referenced By”RelationalAI Documentation └── Build With RelationalAI └── Understand how PyRel works > Use advanced reasoning > Prescriptive reasoning ├── Choose a backend │ ├── Use HiGHS │ │ └── Limitations │ └── Use Ipopt │ └── Limitations └── Solve a decision problem └── Add constraints