예제 #1
0
    def solve(self, name, *args, **kwargs):
        """
        Optimize the model using the named solver.

        Parameters
        ----------
        name : str
            The solver name
        \*args 
            A variable list of arguments.
        \**kwargs
            A variable list of keyword arguments.
        
        Notes
        -----
        The arguments and keyword arguments are the same as supported by Pyomo
        solver objects.
        """
        solver = SolverFactory(name)

        if len(self.model.o) == 0:
            # No objectives defined, so add a dummy objective
            self.model.o.add(1)

        return solver.solve(self.model, *args, **kwargs)
예제 #2
0
    def solve(self, name, *args, **kwargs):
        """
        Optimize the model using the named solver.

        Parameters
        ----------
        name : str
            The solver name
        \*args 
            A variable list of arguments.
        \**kwargs
            A variable list of keyword arguments.
        
        Notes
        -----
        The arguments and keyword arguments are the same as supported by Pyomo
        solver objects.
        """
        solver = SolverFactory(name)
        return solver.solve(self.model, *args, **kwargs)