def test_mumps(self):
        n = 20000
        m = make_model_tri(n, small_val=1e-7)
        interface = InteriorPointInterface(m)
        linear_solver = MumpsInterface()
        # Default memory "buffer" factor: 20
        linear_solver.set_icntl(14, 20)

        kkt = interface.evaluate_primal_dual_kkt_matrix()
        res = linear_solver.do_symbolic_factorization(kkt)
        predicted = linear_solver.get_infog(16)

        self._test_ip_with_reallocation(linear_solver, interface)
        actual = linear_solver.get_icntl(23)

        self.assertTrue(predicted == 12 or predicted == 11)
        self.assertTrue(actual > predicted)
Exemple #2
0
 def test_ip2_mumps(self):
     solver = MumpsInterface()
     self._test_solve_interior_point_2(solver)
 def test_mumps(self):
     solver = MumpsInterface()
     self._test_linear_solvers(solver)
 def test_mumps(self):
     solver = MumpsInterface()
     self._test_solvers(solver, use_tril=True)
Exemple #5
0
import pyomo.environ as pe
from pyomo.contrib.interior_point.interior_point import InteriorPointSolver
from pyomo.contrib.interior_point.interface import InteriorPointInterface
from pyomo.contrib.interior_point.linalg.mumps_interface import MumpsInterface
import logging


logging.basicConfig(level=logging.INFO)
# Supposedly this sets the root logger's level to INFO.
# But when linear_solver.logger logs with debug, 
# it gets propagated to a mysterious root logger with
# level NOTSET...

m = pe.ConcreteModel()
m.x = pe.Var()
m.y = pe.Var()
m.obj = pe.Objective(expr=m.x**2 + m.y**2)
m.c1 = pe.Constraint(expr=m.y == pe.exp(m.x))
m.c2 = pe.Constraint(expr=m.y >= (m.x - 1)**2)
interface = InteriorPointInterface(m)
linear_solver = MumpsInterface(
#        log_filename='lin_sol.log',
        icntl_options={11: 1}, # Set error level to 1 (most detailed)
        )

ip_solver = InteriorPointSolver(linear_solver)
x, duals_eq, duals_ineq = ip_solver.solve(interface)
print(x, duals_eq, duals_ineq)
Exemple #6
0
 def test_mumps(self):
     solver = MumpsInterface()
     self._test_regularization(solver)
Exemple #7
0
    def test_reallocate_memory_mumps(self):

        # Create a tri-diagonal matrix with small entries on the diagonal
        n = 10000
        small_val = 1e-7
        big_val = 1e2
        irn = []
        jcn = []
        ent = []
        for i in range(n - 1):
            irn.extend([i + 1, i, i])
            jcn.extend([i, i, i + 1])
            ent.extend([big_val, small_val, big_val])
        irn.append(n - 1)
        jcn.append(n - 1)
        ent.append(small_val)
        irn = np.array(irn)
        jcn = np.array(jcn)
        ent = np.array(ent)

        matrix = coo_matrix((ent, (irn, jcn)), shape=(n, n))

        linear_solver = MumpsInterface()
        linear_solver.do_symbolic_factorization(matrix)

        predicted = linear_solver.get_infog(16)

        res = linear_solver.do_numeric_factorization(matrix,
                                                     raise_on_error=False)
        self.assertEqual(res.status, LinearSolverStatus.not_enough_memory)

        linear_solver.do_symbolic_factorization(matrix)

        factor = 2
        linear_solver.increase_memory_allocation(factor)

        res = linear_solver.do_numeric_factorization(matrix)
        self.assertEqual(res.status, LinearSolverStatus.successful)

        # Expected memory allocation (MB)
        self.assertEqual(linear_solver._prev_allocation, 2 * predicted)

        actual = linear_solver.get_infog(18)

        # Sanity checks:
        # Make sure actual memory usage is greater than initial guess
        self.assertTrue(predicted < actual)
        # Make sure memory allocation is at least as much as was used
        self.assertTrue(actual <= linear_solver._prev_allocation)