Initializing help system before first use

# XPRSwritesol (WRITESOL)

Purpose
Writes the current solution to a CSV format ASCII file, problem_name .asc (and .hdr).
Topic areas
File IO, Solution
Synopsis
`int XPRS_CC XPRSwritesol(XPRSprob prob, const char *filename, const char *flags);`
`WRITESOL [filename] [-flags]`
Arguments

prob | The current problem.
filename | A string of up to MAXPROBNAMELENGTH characters containing the file name to which the solution is to be written. If omitted, the default problem_name will be used. The extensions .hdr and .asc will be appended.
flags | Flags to control which optional fields are output:
s | sequence number;
n | name;
t | type;
b | basis status;
a | activity;
c | cost (columns), slack (rows);
l | lower bound;
u | upper bound;
d | dj (column; reduced costs), dual value (rows; shadow prices);
r | right hand side (rows).
If no flags are specified, all fields are output. Additional flags:
p | outputs in full precision;
q | only outputs vectors with nonzero optimum value;
x | output the current LP solution instead of the MIP solution;
z | compress the output file.

Related controls
Double

OUTPUTTOL | Tolerance on print values.

String

OUTPUTMASK | Mask to restrict the row and column names output to file.

Example 1 (Library)
In this example the basis status is output (along with the sequence number) following optimization:

    XPRSreadprob(prob, "richard", "");
    XPRSlpoptimize(prob, "");
    XPRSwritesol(prob, "", "sb");

See also example trimloss.c.
Example 2 (Console)
Suppose we wish to produce files containing

- the names and values of variables starting with the letter X which are nonzero and
- the names, values and right hand sides of constraints starting with CO2.

The Optimizer commands necessary to do this are:

    OUTPUTMASK = "X???????"
    WRITESOL XVALS -naq
    OUTPUTMASK = "CO2?????"
    WRITESOL CO2 -nar

Further information
1. This function currently does not apply to general nonlinear problems.
2. The command produces two readable files: filename.hdr (the solution header file) and filename.asc (the CSV format solution file). The header file contains summary information, all in one line. The ASCII file contains one line of information for each row and column in the problem. Any fields appearing in the .asc file will be in the order the flags are described above. The order that the flags are specified by the user is irrelevant.
3. Additionally, the mask control OUTPUTMASK may be used to control which names are reported to the ASCII file. Only vectors whose names match OUTPUTMASK are output. OUTPUTMASK is set by default to " ????????", so that all vectors are output.
Related topics
XPRSgetsolution, XPRSwriteprtsol ( WRITEPRTSOL).
Parent Topic Console and Library Functions

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.