1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*   File....: ratordwrite.c                                                 */
4 /*   Name....: ORD File Write                                                */
5 /*   Author..: Thorsten Koch                                                 */
6 /*   Copyright by Author, All rights reserved                                */
7 /*                                                                           */
8 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9 /*
10  * Copyright (C) 2001-2018 by Thorsten Koch <koch@zib.de>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 3
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25  */
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <ctype.h>
31 #include <assert.h>
32 
33 #include <gmp.h>
34 
35 #include "zimpl/lint.h"
36 #include "zimpl/mshell.h"
37 #include <stdbool.h>
38 #include "zimpl/gmpmisc.h"
39 #include "zimpl/ratlptypes.h"
40 #include "zimpl/numb.h"
41 #include "zimpl/bound.h"
42 #include "zimpl/mme.h"
43 #include "zimpl/mono.h"
44 #include "zimpl/term.h"
45 #include "zimpl/ratlp.h"
46 #include "zimpl/ratlpstore.h"
47 
48 /* A specification for the ORD file format can be found in the
49  * ILOG CPLEX 7.0 Reference Manual page 545.
50  */
lps_orderfile(const Lps * lp,FILE * fp,LpFormat format,const char * text)51 void lps_orderfile(
52    const Lps*  lp,
53    FILE*       fp,
54    LpFormat    format,
55    const char* text)
56 {
57    const Var*  var;
58    int         name_size;
59    char*       vtmp;
60 
61    assert(lp     != NULL);
62    assert(fp     != NULL);
63    assert(format == LP_FORM_LPF || format == LP_FORM_MPS);
64 
65    name_size = lps_getnamesize(lp, format);
66    vtmp      = malloc((size_t)name_size);
67 
68    assert(vtmp != NULL);
69 
70    if (text != NULL)
71       fprintf(fp, "* %s\n", text);
72 
73    fprintf(fp, "NAME        %8.8s\n", lp->name);
74 
75    for(var = lp->var_root; var != NULL; var = var->next)
76    {
77       if (var->vclass == VAR_CON)
78          continue;
79 
80       if (var->size == 0)
81           continue;
82 
83       if (var->type == VAR_FIXED)
84          continue;
85 
86       lps_makename(vtmp, name_size, var->name, var->number);
87 
88       fprintf(fp, "    %-*s  %8d  %.10e\n",
89          name_size - 1, vtmp, var->priority, mpq_get_d(var->startval));
90    }
91    fprintf(fp, "ENDATA\n");
92 
93    free(vtmp);
94 }
95 
96 
97