CAS Sessions

A swat.cas.connection.CAS session is needed in order to use sasoptpy and SAS Optimization solvers to solve optimization problems. You can find more details about CAS sessions in SWAT Documentation.

You can create a sample CAS Session as follows:

>>> import sasoptpy as so
>>> from swat import CAS
>>> s = CAS(hostname=cas_host, username=cas_username, password=cas_password, port=cas_port)
>>> m = so.Model(name='demo', session=s)
>>> print(repr(m))
sasoptpy.Model(name='demo', session=CAS(hostname, port, username, protocol='cas', name='py-session-1', session=session-no))

You can end the session and close the connection as follows:

>>> s.terminate()

SAS Sessions

A saspy.SASsession session is needed in order to use sasoptpy and SAS/OR solvers to solve optimization problems on SAS 9.4 clients.

You can create a sample SAS session as follows:

>>> import sasoptpy as so
>>> import saspy
>>> sas_session = saspy.SASsession(cfgname='winlocal')
>>> m = so.Model(name='demo', session=sas_session)
>>> print(repr(m))
sasoptpy.Model(name='demo', session=saspy.SASsession(cfgname='winlocal'))

You can connect to a SAS session by using a configuration file

In [1]: sas = saspy.SASsession(cfgfile=config_file)
Using SAS Config named: sshsas
SAS Connection established. Subprocess id is 167
In [2]: m = so.Model(name='demo', session=sas)
NOTE: Initialized model demo.
In [3]: print(m.get_session().sasver)

You can terminate the SAS session as follows:

In [4]: sas.endsas()
SAS Connection terminated. Subprocess id was 167