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","."]
code: def _optimize(
      self,
      S: np.ndarray,
      r: Optional[np.ndarray] = None,
      w0: Optional[np.ndarray] = None,
  ) -> np.ndarray:
      # inverse volatility
      if self.method == self.OPT_INV:
          if r is not None:
              warnings.warn(
                  "`r` is set but will not be used for `inv` portfolio"
              )
          if w0 is not None:
              warnings.warn(
                  "`w0` is set but will not be used for `inv` portfolio"
              )
          return self._optimize_inv(S)
  
      # global minimum variance
      if self.method == self.OPT_GMV:
          if r is not None:
              warnings.warn(
                  "`r` is set but will not be used for `gmv` portfolio"
              )
          return self._optimize_gmv(S, w0)
  
      # mean-variance
      if self.method == self.OPT_MVO:
          return self._optimize_mvo(S, r, w0)
  
      # risk parity
      if self.method == self.OPT_RP:
          if r is not None:
              warnings.warn(
                  "`r` is set but will not be used for `rp` portfolio"
              )
          return self._optimize_rp(S, w0)
  
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 3 for calling the PortfolioOptimizer obj's underlying member method code with example usage: obj._optimize(S, r, w0) and returns: self, self, self, self