class_docstr: Portfolio Optimizer
  
  The following optimization algorithms are supported:
      - `gmv`: Global Minimum Variance Portfolio
      - `mvo`: Mean Variance Optimized Portfolio
      - `rp`: Risk Parity
      - `inv`: Inverse Volatility
  
  Note:
      This optimizer always assumes full investment and no-shorting.
class_docstr_tok: ["Portfolio","Optimizer","The","following","optimization","algorithms","are","supported",":","-","`","gmv","`",":","Global","Minimum","Variance","Portfolio","-","`","mvo","`",":","Mean","Variance","Optimized","Portfolio","-","`","rp","`",":","Risk","Parity","-","`","inv","`",":","Inverse","Volatility","Note",":","This","optimizer","always","assumes","full","investment","and","no-shorting","."]
docstr: optimization constraints
  
  Defines the following constraints:
      - no shorting and leverage: 0 <= w <= 1
      - full investment: sum(w) == 1
      - turnover constraint: |w - w0| <= delta
docstr_tok: ["optimization","constraints","Defines","the","following","constraints",":","-","no","shorting","and","leverage",":","0","<","=","w","<","=","1","-","full","investment",":","sum","(","w",")","==","1","-","turnover","constraint",":","|w","-","w0|","<","=","delta"]
code: def _get_constrains(self, w0: Optional[np.ndarray] = None):
      """optimization constraints
  
      Defines the following constraints:
          - no shorting and leverage: 0 <= w <= 1
          - full investment: sum(w) == 1
          - turnover constraint: |w - w0| <= delta
      """
  
      # no shorting and leverage
      bounds = so.Bounds(0.0, 1.0)
  
      # full investment constraint
      cons = [{"type": "eq", "fun": lambda x: np.sum(x) - 1}]  # == 0
  
      # turnover constraint
      if w0 is not None:
          cons.append(
              {
                  "type": "ineq",
                  "fun": lambda x: self.delta - np.sum(np.abs(x - w0)),
              }
          )  # >= 0
  
      return bounds, cons
  
file_path: qlib/qlib/contrib/strategy/optimizer/optimizer.py
imports: import warnings
  import numpy
  import pandas
  import scipy.optimize
  from typing import Optional, Union, Callable, List
  from .base import BaseOptimizer
label_desc: Use image node_id 11 for calling the PortfolioOptimizer obj's underlying member method code with example usage: obj._get_constrains(w0) and returns: bounds,  cons