def write_to_file(self, filename, filetype=None):
if filetype == "<STR_LIT>" and not filename.endswith("<STR_LIT>"):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>elif filetype is None and filename.endswith("<STR_LIT>"):<EOL><INDENT>filetype = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>return super(SteeringHierarchy, self).write_to_file(filename,<EOL>filetype=filetype)<EOL><DEDENT>tempfile_ = tempfile.NamedTemporaryFile()<EOL>tmp_filename = tempfile_.name<EOL>tempfile_.close()<EOL>tmp_dats_filename = tmp_filename + "<STR_LIT>"<EOL>write_to_sdpa(self, tmp_dats_filename)<EOL>f = open(tmp_dats_filename, '<STR_LIT:r>')<EOL>f.readline();f.readline();f.readline()<EOL>blocks = ((f.readline().strip().split("<STR_LIT>")[<NUM_LIT:0>])[<NUM_LIT:1>:-<NUM_LIT:1>]).split("<STR_LIT:U+002CU+0020>")<EOL>block_offset, matrix_size = [<NUM_LIT:0>], <NUM_LIT:0><EOL>for block in blocks:<EOL><INDENT>matrix_size += abs(int(block))<EOL>block_offset.append(matrix_size)<EOL><DEDENT>f.readline()<EOL>matrix = [[<NUM_LIT:0> for _ in range(matrix_size)] for _ in range(matrix_size)]<EOL>for line in f:<EOL><INDENT>entry = line.strip().split("<STR_LIT:\t>")<EOL>var, block = int(entry[<NUM_LIT:0>]), int(entry[<NUM_LIT:1>])-<NUM_LIT:1><EOL>row, column = int(entry[<NUM_LIT:2>]) - <NUM_LIT:1>, int(entry[<NUM_LIT:3>]) - <NUM_LIT:1><EOL>value = float(entry[<NUM_LIT:4>])<EOL>offset = block_offset[block]<EOL>matrix[offset+row][offset+column] = int(value*var)<EOL>matrix[offset+column][offset+row] = int(value*var)<EOL><DEDENT>f.close()<EOL>f = open(filename, '<STR_LIT:w>')<EOL>for matrix_line in matrix:<EOL><INDENT>f.write(str(matrix_line).replace('<STR_LIT:[>', '<STR_LIT>').replace('<STR_LIT:]>', '<STR_LIT>') + '<STR_LIT:\n>')<EOL><DEDENT>f.close()<EOL>os.remove(tmp_dats_filename)<EOL>
Write the relaxation to a file.

        :param filename: The name of the file to write to. The type can be
                         autodetected from the extension: .dat-s for SDPA,
                         .task for mosek, .csv for human readable format, or
                         .txt for a symbolic export
        :type filename: str.
        :param filetype: Optional parameter to define the filetype. It can be
                         "sdpa" for SDPA , "mosek" for Mosek, "csv" for
                         human readable format, or "txt" for a symbolic export.
        :type filetype: str.