A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://scipopt.github.io/PySCIPOpt/docs/html/expr_8pxi.html below:

PySCIPOpt: src/pyscipopt/expr.pxi File Reference

In this file we implemenet the handling of expressions.

 We have two types of expressions: Expr and GenExpr.
 The Expr can only handle polynomial expressions.
 In addition, one can recover easily information from them.
 A polynomial is a dictionary between `terms` and coefficients.
 A `term` is a tuple of variables
 For examples, 2*x*x*y*z - 1.3 x*y*y + 1 is stored as a
 {Term(x,x,y,z) : 2, Term(x,y,y) : -1.3, Term() : 1}
 Addition of common terms and expansion of exponents occur automatically.
 Given the way `Expr`s are stored, it is easy to access the terms: e.g.
 expr = 2*x*x*y*z - 1.3 x*y*y + 1
 expr[Term(x,x,y,z)] returns 1.3
 expr[Term(x)] returns 0.0
 On the other hand, when dealing with expressions more general than polynomials,
 that is, absolute values, exp, log, sqrt or any general exponent, we use GenExpr.
 GenExpr stores expression trees in a rudimentary way.
 Basically, it stores the operator and the list of children.
 We have different types of general expressions that in addition
 to the operation and list of children stores
 SumExpr: coefficients and constant
 ProdExpr: constant
 Constant: constant
 VarExpr: variable
 PowExpr: exponent
 UnaryExpr: nothing
 We do not provide any way of accessing the internal information of the expression tree,
 nor we simplify common terms or do any other type of simplification.
 The `GenExpr` is pass as is to SCIP and SCIP will do what it see fits during presolving.
 TODO: All this is very complicated, so we might wanna unify Expr and GenExpr.
 Maybe when consexpr is released it makes sense to revisit this.
 TODO: We have to think about the operations that we define: __isub__, __add__, etc
 and when to copy expressions and when to not copy them.
 For example: when creating a ExprCons from an Expr expr, we store the expression expr
 and then we normalize. When doing the normalization, we do
 ```
 c = self.expr[CONST]
 self.expr -= c
 ```
 which should, in princple, modify the expr. However, since we do not implement __isub__, __sub__
 gets called (I guess) and so a copy is returned.
 Modifying the expression directly would be a bug, given that the expression might be re-used by the user. 

Definition in file expr.pxi.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4