Snippet:Read cplex .sol file

From HUES Platform Wiki
Description Python script for reading .sol output file of the cplex solver
Author(s) Boran Morvaj
Language Python
Tags cplex, aimms, python
Snippet code ########################
def readsolution(filename):
   try:
       from xml.etree import ElementTree
       document = ElementTree.parse( filename )
       values=[]
       
       for variable in document.findall('variables/variable'): #go to variables section and read all variable subsections
            values.append()=variable.attrib['value']
                    
       return values
   except:
       return 'Error, couldn\'t open the file'
Notes