[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Time conversion functions
From: |
Xypron |
Subject: |
Re: [Help-glpk] Time conversion functions |
Date: |
Sat, 22 Nov 2008 23:14:19 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081030 SeaMonkey/1.1.13 |
Hello Andrew,
Moreover, probably it would be reasonable to have a function, say,
sprintf, to convert one or several values to a character string to be
assigned to a symbolic parameter or used in symbolic computations.
in AMPL such a function is defined:
sprintf(fmt, exprlist ) - format arguments according to format string fmt,
exprlist is optional
The string fmt uses the same format as printf.
Example:
param T := 4;
set W := setof{t in 1..T} sprintf("W%3.1f", 0.1*t);
display W;
The information is extracted from the book
Robert Fourer, "AMPL - A modeling Language for mathematical programming", 2003
Such function would be especially useful in the context of the table statement.
Currently properly formatting fields for SQL, CSV, ... is not possible in GLPK.
It is not sufficient, because there should be a check that the
character string to be converted is correct. In glpk there are two
routines str2int and str2num intended to perform such conversion.
You are right, str2num (defined in glplib11.c) could be used instead of atof
for automatic conversion of symbols to numeric. Atof is less restrictive, it
converts a string starting with a number followed by text to a numeric
representation of the number. It simply returns 0 if the string does not start
with a number:
double a = atof(" 13 eggs"); // a is set to 13
double a = atof("eggs: 13"); // a is set to 0
Best regards
Xypron
- RE: [Help-glpk] Time conversion functions, (continued)
- Re: [Help-glpk] Time conversion functions, Maurice Diamantini, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22
- Re: [Help-glpk] Time conversion functions,
Xypron <=
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Xypron, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/23
- Message not available
- Message not available
- Message not available
- Message not available
- Re: [Help-glpk] Time conversion functions, Xypron, 2008/11/24
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/25
- Re: [Help-glpk] Time conversion functions, glpk xypron, 2008/11/25
Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/18
Re: [Help-glpk] Time conversion functions, Harley Mackenzie, 2008/11/18
Re: [Help-glpk] Time conversion functions, Nigel Galloway, 2008/11/19
Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22