def test_doc(self): kestrel = kestrelAMPL() tmp = [tuple(name.split(':')) for name in kestrel.solvers()] amplsolvers = set(v[0].lower() for v in tmp if v[1] == 'AMPL') doc = pyomo.neos.doc dockeys = set(doc.keys()) self.assertEqual(amplsolvers, dockeys)
def available(self): if self.neos_available is None: self.neos_available = False try: if kestrelAMPL().neos is not None: self.neos_available = True except: pass return self.neos_available
def test_connection_failed(self): try: orig_host = pyomo.neos.kestrel.NEOS.host pyomo.neos.kestrel.NEOS.host = 'neos-bogus-server.org' with LoggingIntercept() as LOG: kestrel = kestrelAMPL() self.assertIsNone(kestrel.neos) self.assertRegex(LOG.getvalue(), "NEOS is temporarily unavailable:\n\t\(.+\)") finally: pyomo.neos.kestrel.NEOS.host = orig_host
import pyomo.common.unittest as unittest from pyomo.common.log import LoggingIntercept from pyomo.scripting.pyomo_main import main from pyomo.scripting.util import cleanup from pyomo.neos.kestrel import kestrelAMPL import pyomo.neos import pyomo.environ as pyo from pyomo.common.fileutils import this_file_dir currdir = this_file_dir() neos_available = False try: if kestrelAMPL().neos is not None: neos_available = True except: pass email_set = True if os.environ.get('NEOS_EMAIL') is None: email_set = False def _model(sense): # Goals of this model: # - linear # - solution has nonzero variable values (so they appear in the results) model = pyo.ConcreteModel() model.y = pyo.Var(bounds=(-10, 10), initialize=0.5)
# import os from os.path import abspath, dirname, join currdir = dirname(abspath(__file__)) import pyutilib.th as unittest import pyomo.scripting.pyomo_command as main from pyomo.scripting.util import cleanup from pyomo.neos.kestrel import kestrelAMPL from six import iteritems try: kestrel = kestrelAMPL() except: kestrel = None if kestrel is None or kestrel.neos is None: using_neos = False else: using_neos = True kestrel = None try: import yaml yaml_available=True except ImportError: yaml_available=False
import pyutilib.th as unittest import pyomo.scripting.pyomo_command as main from pyomo.scripting.util import cleanup from pyomo.neos.kestrel import kestrelAMPL import pyomo.environ as pyo from six import iteritems neos_available = False try: # Attempt a connection to NEOS. Any failure will result in skipping # these tests if kestrelAMPL().neos is not None: neos_available = True except: pass try: import yaml yaml_available=True except ImportError: yaml_available=False # # Because the Kestrel tests require connections to the NEOS server, and # that can take quite a while (5-20+ seconds), we will only run these # tests as part of the nightly suite (i.e., by the CI system as part of