Ejemplo n.º 1
0
 def get_sparsity_in(self, i):
     n = nlpsol_out(i)
     if n == "f":
         return Sparsity.scalar()
     elif n in ("x", "lam_x"):
         return Sparsity.dense(self.nx)
     elif n in ("g", "lam_g"):
         return Sparsity.dense(self.ng)
     else:
         return Sparsity(0, 0)
Ejemplo n.º 2
0
    def get_sparsity_in(self, i: int) -> tuple:
        """
        Get the sparsity of a specific variable

        Parameters
        ----------
        i: int
            The index of the variable

        Returns
        -------
        The sparsity of the variable
        """

        n = nlpsol_out(i)
        if n == "f":
            return Sparsity.scalar()
        elif n in ("x", "lam_x"):
            return Sparsity.dense(self.nx)
        elif n in ("g", "lam_g"):
            return Sparsity.dense(self.ng)
        else:
            return Sparsity(0, 0)