📄 read.w,v
字号:
head 1.143;access david neto;symbols zero-five-zero:1.143 zero-four-seventeen:1.142 zero-four-ten:1.140 zero-four-nine:1.140 zero-four-eight:1.140 zero-four-five:1.140 zero-four-three:1.140 zero-four-zero:1.135;locks neto:1.143;1.143date 98.12.05.22.37.29; author neto; state Exp;branches;next 1.142;1.142date 98.10.10.19.26.20; author neto; state Exp;branches;next 1.141;1.141date 98.10.08.15.14.47; author neto; state Exp;branches;next 1.140;1.140date 98.07.31.17.56.24; author neto; state Exp;branches;next 1.139;1.139date 98.07.31.17.51.53; author neto; state Exp;branches;next 1.138;1.138date 98.07.25.22.10.34; author neto; state Exp;branches;next 1.137;1.137date 98.07.25.18.10.50; author neto; state Exp;branches;next 1.136;1.136date 98.07.24.20.38.33; author neto; state Exp;branches;next 1.135;1.135date 98.07.16.21.58.55; author neto; state Exp;branches;next 1.134;1.134date 98.05.08.22.23.57; author neto; state Exp;branches;next 1.133;1.133date 97.12.13.20.05.45; author neto; state Exp;branches;next 1.132;1.132date 97.12.13.20.03.05; author neto; state Exp;branches;next 1.131;1.131date 97.12.13.17.25.18; author neto; state Exp;branches;next 1.130;1.130date 97.10.18.15.16.19; author neto; state Exp;branches;next 1.129;1.129date 97.10.17.21.47.44; author neto; state Exp;branches;next 1.128;1.128date 97.10.17.21.00.25; author neto; state Exp;branches;next 1.127;1.127date 97.09.27.18.04.39; author neto; state Exp;branches;next 1.126;1.126date 97.08.15.20.18.25; author neto; state Exp;branches;next 1.125;1.125date 97.05.16.18.11.41; author neto; state Exp;branches;next 1.124;1.124date 97.05.16.18.09.40; author neto; state Exp;branches;next 1.123;1.123date 97.02.10.19.25.03; author neto; state Exp;branches;next 1.122;1.122date 97.02.10.19.16.26; author neto; state Exp;branches;next 1.121;1.121date 97.02.10.19.13.51; author neto; state Exp;branches;next 1.120;1.120date 97.01.21.21.55.55; author david; state Exp;branches;next 1.119;1.119date 96.12.20.14.02.47; author neto; state Exp;branches;next 1.118;1.118date 96.12.13.17.11.23; author neto; state Exp;branches;next 1.117;1.117date 96.12.13.14.44.43; author neto; state Exp;branches;next 1.116;1.116date 96.12.05.14.43.16; author neto; state Exp;branches;next 1.115;1.115date 96.09.12.15.25.37; author neto; state Exp;branches;next 1.114;1.114date 96.08.16.13.05.01; author neto; state Exp;branches;next 1.113;1.113date 96.08.15.14.01.29; author neto; state Exp;branches;next 1.112;1.112date 96.08.15.12.34.25; author neto; state Exp;branches;next 1.111;1.111date 96.07.29.17.07.58; author neto; state Exp;branches;next 1.110;1.110date 96.07.29.16.24.28; author neto; state Exp;branches;next 1.109;1.109date 96.07.29.16.22.58; author neto; state Exp;branches;next 1.108;1.108date 96.07.29.16.20.09; author neto; state Exp;branches;next 1.107;1.107date 96.07.26.17.12.12; author neto; state Exp;branches;next 1.106;1.106date 96.07.15.21.20.37; author david; state Exp;branches;next 1.105;1.105date 96.07.04.16.19.25; author david; state Exp;branches;next 1.104;1.104date 96.06.24.12.25.55; author neto; state Exp;branches;next 1.103;1.103date 96.06.21.13.56.33; author neto; state Exp;branches;next 1.102;1.102date 96.06.21.13.56.11; author neto; state Exp;branches;next 1.101;1.101date 96.05.30.13.25.30; author neto; state Exp;branches;next 1.100;1.100date 96.05.29.11.13.21; author neto; state Exp;branches;next 1.2;1.2date 96.03.15.16.00.15; author neto; state Exp;branches;next 1.1;1.1date 96.03.04.13.55.02; author neto; state Exp;branches;next ;desc@Read TSPLIB files.@1.143log@Added forced write in matrix form.@text@@@i myboiler.w\noindent Copyright \copyright 1994, 1995, 1996, 1997, 1998 David Neto\smallskip\noindent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.\smallskip\noindent This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.\smallskip\noindent You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\smallskip\noindent You may contact David Neto via email at {\tt netod@@@@acm.org}, or with greater latency at\smallskip\noindent{\obeylines Department of Computer Science University of Toronto 10 King's College Rd. Toronto, Ontario M5S 3G4 Canada}\medskip\noindent\hbox{}\hrule\hbox{}\penalty-1000\vskip0.5cm\relax@@i webdefs.w@@i types.w{\obeylines$Log: read.w,v $Revision 1.142 1998/10/10 19:26:20 netoSupport DSJ RANDOM, ATT, and GEOBetter error messages.Revision 1.141 1998/10/08 15:14:47 netoAllow clipping of last point on output too.Revision 1.140 1998/07/31 17:56:24 netoDoh! needed a break too.Revision 1.139 1998/07/31 17:51:53 netoadded default: to satisfy GCC's complaint about missing RANDOM EDGESin a switch.Revision 1.138 1998/07/25 22:10:34 netoRemove the lexicographically last vertex.Revision 1.137 1998/07/25 18:10:50 netoSome of forcing even number of vertic3s.Revision 1.136 1998/07/24 20:38:33 netoAdded changes to allow truncating the odd vertex out.Not finished.Revision 1.135 1998/07/16 21:58:55 netoAdded the LGPL notice in each file.Revision 1.134 1998/05/08 22:23:57 netoBetter comment.Also, added writing abilities for matrix forms.Revision 1.133 1997/12/13 20:05:45 netoOk, so I got the name of write... wrongRevision 1.132 1997/12/13 20:03:05 netoAdded first (compiling) draft of write tsp instanceRevision 1.131 1997/12/13 17:25:18 netoStripped the newlines off the error messages.Revision 1.130 1997/10/18 15:16:19 netoMore readability (matchword).Hopefully fix garbage output on error (move keyword[0]=0).Added support for CEIL 2DRevision 1.129 1997/10/17 21:47:44 netoFixed to compile.Revision 1.128 1997/10/17 21:00:25 netoMade coordinates indexed by number, not name, i.e. x[0] and x[1] insteadof x and y. This reduces the code size in kdtree by removingthe CUTDIMEN kludge.Revision 1.127 1997/09/27 18:04:39 netoFixed RCS log behaviourRevision 1.126 1997/08/15 20:18:25 netoAdded Index major section.Revision 1.125 1997/05/16 18:11:41 netoBreak locks by david and neto.Include <config.h> and "lkconfig.h"Revision 1.124 1997/05/16 18:09:40 netoInclude <config.h> and lkconfig.hRevision 1.123 1997/02/10 19:25:03 netoLimit the size of the PostScript arrays.Revision 1.122 1997/02/10 19:16:26 netoFixed printf spec.Revision 1.121 1997/02/10 19:13:51 netoChanged debugging PostScript output so that we don't depend onlarge (>8191 element) arrays.Revision 1.120 1997/01/21 21:55:55 davidAdded standard copyright notice by including copyrt.wRevision 1.119 96/12/20 14:02:47 netoMake EOF optional. Revision 1.118 96/12/13 17:11:23 netoMake hypot optional.Revision 1.117 96/12/13 14:44:43 netoUsed hypot instead of sqrt.Also, added cost\_from\_euc2d\_raw.Revision 1.116 96/12/05 14:43:16 netoAdded support for no rounding.Revision 1.115 96/09/12 15:25:37 netoEmpty input doesn't print a garbage keyword now.Revision 1.114 96/08/16 13:05:01 netoAdded fixincludes.Revision 1.113 96/08/15 14:01:29 netoMake it pass all flags, except for error problem.Revision 1.112 96/08/15 12:34:25 netoMake it pass -WallRevision 1.111 96/07/29 17:07:58 netoFixed to compile.Revision 1.110 96/07/29 16:24:28 netooops. TeX again.Revision 1.109 96/07/29 16:22:58 netoTeX barfed on the Log.Revision 1.108 96/07/29 16:20:09 netoAdded *\_rcs\_id.Made sure RCS log is activated within this file.}@@*Reading TSPLIB files.The {\sc READ\_ME} included with {\sc TSPLIB} describes the file format.We restrict our attention to the case where the arc lengths are givenin matrix form, or are assumed to be the Euclidean lengths in two dimensions.Here is the outline of this module.@@c#include <config.h>#include "lkconfig.h"#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <math.h>#include "fixincludes.h"@@<Other includes@@>@@;#include "read.h"@@<Global variables@@>@@;@@<Module definitions@@>@@;@@<Module variables@@>@@;@@<Module subroutines@@>@@;@@<Subroutines@@>@@;const char *read_rcs_id="$Id: read.w,v 1.142 1998/10/10 19:26:20 neto Exp neto $";@@ The header file for this module is also included into this module.It provides type definitions and declarations of publicly accessiblevariables and subroutines.@@(read.h@@>=extern const char *read_rcs_id;@@<Type definitions@@>@@;@@<Exported variables@@>@@;@@<Exported subroutines@@>@@;@@ These routines deal with only one problem at a time. We keep a pointer to the current problem in the variable |p|.This is convenient to the users of these routines because that meansthey don't have to pass an extra pointer on every function call.This is also more efficient because we expect the edge cost functionto be evaluated thousands and maybe millions of times.@@<Global variables@@>=static tsp_instance_t *p;@@ We provide a mechanism to switch contexts. The user supplies theproblem that becomes the new context, and receives the currentcontext.@@<Subroutines@@>=tsp_instance_t *switch_to(tsp_instance_t *new_problem){ tsp_instance_t *old_problem; old_problem = p; p = new_problem; @@<Set the |cost| function according to the current context@@>@@; return old_problem;}@@ The switching routine is made publicly available.@@<Exported subroutines@@>=tsp_instance_t *switch_to(tsp_instance_t *new_problem);@@ The routine that actually does the reading is passed the file nameand fills the current context. If a previous context exists, thenit should be saved with a call such as |saved_problem = switch_to(NULL)|, or it should be freed.@@<Subroutines@@>=tsp_instance_t *read_tsp_file(FILE *in, FILE *debug, const int force_even_num){ p=new_of(tsp_instance_t); @@<Set the instance defaults@@>@@; @@<Read in the instance@@>@@; @@<Check consistency@@>@@; @@<Possibly remove a vertex@@>@@; @@<Debugging output@@>@@; return p;}@@ We've used an allocation macro, so we should include the header filewhere it is defined. We also need to know the error checking interface.@@<Other includes@@>=#include "memory.h"#include "error.h"@@ We make the reading routine publicly available.@@<Exported subroutines@@>=tsp_instance_t *read_tsp_file(FILE *in, FILE *out, const int remove_odd_vertex);@@ The |tsp_instance_t| type contains fields that identify and specify the problem.The |name| field is the name given by the TSPLIB maintainers to this problem.It is useful as a basename for the file, though we don't enforce suchusage. The |comment| field is the one-line comment attached to this graph.The |n| field is the number of cities in the instance. Some problems, such as weighted perfect matching, require the graphto have an even number of vertices. In that case after reading in thefull instance, we might remove one vertex. We store the number ofvertices presented on the input in the field |input_n|:it might be odd and 1 more than |n|.The |scale| entry is used to scale random edge lengths. So far itis used only by |DSJ_RANDOM|-type instances.@@<Type definitions@@>=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -