[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eLinearExpr\u003c/code\u003e represents a linear expression in the CP-SAT solver, which can be constructed from variables, constants, or combinations thereof.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for accessing the coefficients, variables, and constant term of the expression.\u003c/p\u003e\n"],["\u003cp\u003eStatic methods like \u003ccode\u003eSum\u003c/code\u003e, \u003ccode\u003eTerm\u003c/code\u003e, and \u003ccode\u003eWeightedSum\u003c/code\u003e offer convenient ways to build complex linear expressions.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLinearExpr\u003c/code\u003e objects can be converted to and from their protocol buffer representation using \u003ccode\u003eFromProto\u003c/code\u003e and \u003ccode\u003eDebugString\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can check if an expression is constant using \u003ccode\u003eIsConstant\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `LinearExpr` class in C++ provides methods to construct and manipulate linear expressions. Key actions include constructing expressions from Boolean or integer variables, constants, or their proto representations. It supports calculating sums and weighted sums of variables and retrieving coefficients, the constant term, and variable indices. Methods are available to check if an expression is constant. It can also create expressions based on a variable times a coefficient and return a debug string.\n"],null,["# LinearExpr\n\nC++ Reference: class LinearExpr\n===============================\n\n\nNote: This documentation is automatically generated.\n\n| Method ||\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`coefficients`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L292) | Return type: `const std::vector\u003cint64_t\u003e& ` Returns the vector of coefficients. |\n| [`constant`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L298) | Return type: `int64_t ` Returns the constant term. |\n| [`DebugString`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L305) | Return type: `std::string ` Arguments: `const CpModelProto* proto = nullptr` \u003cbr /\u003e |\n| [`FromProto`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L281) | Return type: `static LinearExpr ` Arguments: `const LinearExpressionProto& proto` Constructs a linear expr from its proto representation. |\n| [`IsConstant`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L295) | Return type: `const bool ` Returns true if the expression has no variables. |\n| [`LinearExpr`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L244) | Creates an empty linear expression with value zero. |\n| [`LinearExpr`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L250) | \u003cbr /\u003e Arguments: `BoolVar var` Constructs a linear expression from a Boolean variable. It deals with logical negation correctly. |\n| [`LinearExpr`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L253) | \u003cbr /\u003e Arguments: `IntVar var` Constructs a linear expression from an integer variable. |\n| [`LinearExpr`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L256) | \u003cbr /\u003e Arguments: `int64_t constant` Constructs a constant linear expression. |\n| [`Sum`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L261) | Return type: `static LinearExpr ` Arguments: `absl::Span\u003cconst IntVar\u003e vars` Constructs the sum of a list of variables. |\n| [`Sum`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L264) | Return type: `static LinearExpr ` Arguments: `absl::Span\u003cconst BoolVar\u003e vars` Constructs the sum of a list of Boolean variables. |\n| [`Term`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L275) | Return type: `static LinearExpr ` Arguments: `IntVar var, int64_t coefficient` Constructs var \\* coefficient. |\n| [`Term`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L278) | Return type: `static LinearExpr ` Arguments: `BoolVar var, int64_t coefficient` Constructs bool \\* coefficient. |\n| [`variables`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L289) | Return type: `const std::vector\u003cint\u003e& ` Returns the vector of variable indices. |\n| [`WeightedSum`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L267) | Return type: `static LinearExpr ` Arguments: `absl::Span\u003cconst IntVar\u003e vars, absl::Span\u003cconst int64_t\u003e coeffs` Constructs the scalar product of variables and coefficients. |\n| [`WeightedSum`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L271) | Return type: `static LinearExpr ` Arguments: `absl::Span\u003cconst BoolVar\u003e vars, absl::Span\u003cconst int64_t\u003e coeffs` Constructs the scalar product of Boolean variables and coefficients. |"]]