[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-289331-105":59,"doc-detail-289331-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","specifying-data-chapter-9-ampl","Specifying Data - Chapter 9 - AMPL","","Chapter 9 explains how AMPL distinguishes an optimization model from the data values that define a specific instance. It focuses on AMPL data statements and the commands that read them, including the data command for formatted data files (often ending in .dat) and the read command for unformatted lists. The chapter covers whitespace and separator rules, quoting requirements for strings and numeric-looking tokens, mode transitions between data and model, and mechanisms for combining multiple data files while avoiding or intentionally accepting duplicate assignments.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/specifying-data-chapter-9-ampl/289331/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/specifying-data-chapter-9-ampl/289331.png","ImageObject",300,407,{"name":92,"@type":93},"Stanford","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-10-20","2026-09-17",true,{"@type":102,"interactionType":103,"userInteractionCount":52},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is the difference between an AMPL model and the data values for an instance?","Question",{"text":112,"@type":113},"The AMPL model defines the structure (sets, parameters, variables, objectives, and constraints), while the data values specify a particular instance of that optimization problem.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How does the data command read formatted data in AMPL?",{"text":117,"@type":113},"The data command initiates data mode using a file name, for example data diet.dat;, so subsequent input is interpreted as data statements read from that file.",{"name":119,"@type":110,"acceptedAnswer":120},"When do string values in AMPL data mode need to be quoted?",{"text":121,"@type":113},"AMPL generally accepts strings without quotes, but strings containing characters other than letters, digits, underscores, period, +, or - must be quoted; tokens that look like numbers must also be quoted to avoid being treated as numeric values.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},289331,1790508300,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":52,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":144,"read_time":145},2336477552062,"https://ap-avatar.wpscdn.com/davatar_994ba38a5ba835b3df7d355c54d3ed8d","Copyright © 2003 by Robert Fourer, David M. Gay and Brian W. Kernighan  \n9  \n________________________________________________________________________  \n________________________  \nSpecifying Data  \nAs we emphasize throughout this book, there is a distinction between an AMPL model for an optimization problem, and the data values that define a particular instance of the problem. Chapters 5 through 8 focused on the declarations of sets, parameters, variables, objectives and constraints that are necessary to describe models. In this chapter and the next, we take a closer look at the statements that specify the data.  \nExamples of AMPL data statements appear in almost every chapter. These statements offer several formats for lists and tables of set and parameter values. Some formats are most naturally created and maintained in a text editing or word processing environment, while others are easy to generate from programs like database systems and spreadsheets. The display command (Chapter 12) also produces output in these formats. Wherever possible, similar syntax and concepts are used for both sets and parameters.  \nThis chapter first explains how AMPL’s data command is used, in conjunction with data statements, to read data values from files such as those whose names end in .dat throughout our examples. Options to the data command also allow or force selected sets and parameters to be read again.  \nSubsequent sections describe data statements, first for lists and then for tables of set and parameter data, followed by brief sections on initial values for variables, values for indexed collections of sets, and default values. A summary of data statement formats appears in Section A.12 .  \nA final section describes the read command, which reads unformatted lists of values into sets and parameters. Chapter 10 is devoted to AMPL’s features for data stored in relational database tables.  \n9.1 Formatted data: the data command  \nDeclarations like param and var, and commands like solve and display, are executed in model mode , the standard mode for most modeling activity. But model mode is inconvenient for reading long lists of set and parameter values. Instead AMPL reads its  \ndata statements in a data mode that is initiated by the data command. In its most common use, this command consists of the keyword data followed by the name of a file. For example,  \nampl: data diet.dat;  \nreads data from a file named diet .dat. Filenames containing spaces, semicolons, or nonprinting characters must be enclosed in quotes.  \nWhile reading in data mode, AMPL treats white space, that is, any sequence of space, tab, and ‘‘newline’’ characters, as a single space. Commas separating strings or numbers are also ignored. Judicious use of these separators can help to arrange data into easy-toread lists and tables; our examples use a combination of spaces and newlines. If data statements are produced as output from other data management software and sent directly to AMPL, however, then you may ignore visual appearance and use whatever format is convenient.  \nData files often contain numerous character strings, representing set members or the values of symbolic parameters. Thus in data mode AMPL does not, in general, require strings to be enclosed in quotes. Strings that include any character other than letters, digits, underscores, period, + and-must be quoted, however, as in the case of A&P. You may use a pair of either single quotes (’A&P’) or double quotes ( \"A&P\"), unless the string contains a quote, in which case the other kind of quote must surround it (\"DOMINICK’S\") or the surrounding quote must be doubled within it (’DOMINICK’’S’) .  \nA string that looks like a number (for example \"+1\" or \"3e4\") must also be quoted, to distinguish it from a set member or parameter value that is actually a number. Numbers that have the same internal representation are considered to be the same, so that for example 2, 2.00, 2 .e0 and 0 .02E+2 all denote the same set member","cbCailgf5RKtpL7s","https://ap.wps.com/l/cbCailgf5RKtpL7s","pdf",167248,25,"English","# 9.1 Formatted data: the data command\n## 9.2 Data in lists","[{\"question\":\"What is the difference between an AMPL model and the data values for an instance?\",\"answer\":\"The AMPL model defines the structure (sets, parameters, variables, objectives, and constraints), while the data values specify a particular instance of that optimization problem.\"},{\"question\":\"How does the data command read formatted data in AMPL?\",\"answer\":\"The data command initiates data mode using a file name, for example data diet.dat;, so subsequent input is interpreted as data statements read from that file.\"},{\"question\":\"When do string values in AMPL data mode need to be quoted?\",\"answer\":\"AMPL generally accepts strings without quotes, but strings containing characters other than letters, digits, underscores, period, +, or - must be quoted; tokens that look like numbers must also be quoted to avoid being treated as numeric values.\"}]","Specifying Data - Chapter 9 - AMPL | PDF",1789634992,63]