3 Set Related Functions 41 ActiveCard The function ActiveCard returns the cardinality of active elements in its identifier argument, or the cardinality of active elements of a suffix of that identifier. Card( Identifier, [Suffix]! (input identifier reference! (optional element in the set AllSuffixNames Identifier A reference to a set or an indexed identifier. Suffix An element in the predefined set AllSuffixNames. If Identifier is a set, the function ActiveCard returns the number of active elements in Identifier. If Identifier is an indexed identifier, the function ActiveCard returns the number of nondefault values stored for Identifier. If Suffix is given, the number of nondefault values stored for the given suffix of Identifier. Remarks: The ActiveCard function cannot be applied to slices of indexed identifiers. In such a case, you can use the Count operator to count the number of nondefault elements. See also: The function Card and Count operator (see also Section of the Language Reference.

4 Set Related Functions 42 Card The function Card returns the cardinality of its identifier argument, or of the cardinality of a suffix of that identifier. Card( Identifier, [Suffix]! (input identifier reference! (optional element in the set AllSuffixNames Identifier A reference to a set or an indexed identifier. Suffix An element in the predefined set of AllSuffixNames. If Identifier is a set, the function Card returns the number of elements in Identifier. If Identifier is an indexed identifier, the function Card returns the number of nondefault values stored for Identifier. If Suffix is given, the number of nondefault values stored for the given suffix of Identifier. Remarks: The Card function cannot be applied to slices of indexed identifiers. In such a case, you can use the Count operator to count the number of nondefault elements. When the Card function is used inside the definition of a parameter or a set and the first argument is an index or element parameter into the set AllIdentifiers then the definition depends on all identifiers that can appear on the left hand side of an assignment (sets without a definition, parameters without a definition, variables and constraints. The cardinality will be computed for all identifiers, including those with a definition. These definitions will not be made up to date, however. This is illustrated in the following example. PARAMETER: identifier : A ; PARAMETER: identifier : B definition : A + 1 ; PARAMETER: identifier : TheCards index domain : IndexIdentifiers definition : Card( IndexIdentifiers, Level ; body: A := 1 ; display TheCards ;

5 Set Related Functions 43 See also: Here TheCards is computed in the display statement because A just changed. The definition of TheCards, that is made up to date by the display statement, will, however, not invoke the computation of B, although it is not up to date. This is done in order to avoid circular references while making set and parameter definitions up to date. In order to make B up to date consider using the Update statement, see also Section 7.3 of the Language Reference. The function ActiveCard and the Count operator (see also Section of the Language Reference.

6 Set Related Functions 44 CloneElement The procedure CloneElement copies the data associated with a particular element to another element. CloneElement( updateset,! (input, output a set identifier originalelement,! (input an element in the set clonename,! (input a string that is the name of the clone cloneelement,! (output an element parameter includedefinedsubsets! (optional an integer, default 0. The procedure CloneElement performs the following actions: 1. It creates or finds an element with name clonename: cloneelement. The element cloneelement is inserted into updateset if it is not already there. This insertion is only permitted if updateset does not have a definition. 2. For each domain set of updateset, say insertdomainset, the element cloneelement is inserted into insertdomainset if it is not already there. Such an insertion is only permitted if insertdomainset does not have a definition. 3. For each subset of updateset, say insertsubset in which originalelement is an element, cloneelement is also inserted into insertsubset. If includedefinedsubsets is 0, then insertsubset is skipped if it is a defined subset. 4. The domain sets of steps 1 and 2, and the sets modified in step 3 form a set, say modifiedsets. 5. Identifiers declared over a set in modifiedsets that meet one of the following criteria, are selected: It is a non-local multi-dimensional set without a definition. It is a non-local parameter without a definition. It is a variable. It is a constraint. These identifiers form the set modifiedidentifiers. 6. For each identifier in the set modifiedidentifiers, and all suffixes of this identifier, the data associated with element originalelement is copied to cloneelement. updateset A one-dimensional non-compound set. originalelement An element valued expression that should result in an element in updateset. clonename A string expression that should result in a name that is in the set updateset or can be added to that set.

7 Set Related Functions 45 cloneelement An element parameter, in which the resulting element is stored. includedefinedsubsets When non-zero, defined subsets are included in the modifiedsets as well. When these defined subsets are evaluated thereafter again, this may result in the creation of inactive data. Inactive data can be removed by a CLEANUP or CLEANDEPENDENTS statement, see Section 24.3 of the Language Reference. Defined subsets that are defined as an enumeration are never included. The procedure returns 1 if successful and 0 otherwise. Possible reasons for returning 0 are: originalelement is not in updateset. clonename equals name of originalelement. There are no identifiers modified. Remarks: If you want to make sure that the string clonename is not yet an element in updateset, use a statement like: if ( not ( clonename in updateset then CloneElement(... ; endif ; Example: With the following declarations (and initial data: SET: identifier : S index : i, j parameter : ep initial data : data { a } ; PARAMETER: identifier : P index domain : i initial data : data { a : 1 } ; PARAMETER: identifier : Q index domain : (i,j initial data : data { ( a, a : 1 } ; the statement CloneElement( S, a, "b", ep ; results in S, P, Q and ep having the following data:

9 Set Related Functions 47 ConstraintVariables The function ConstraintVariables returns all the symbolic variables that are referred in a certain collection of constraints, including the variables that are referred in the definitions of these variables. ConstraintVariables( Contraints! (input a subset of AllConstraints Contraints The set of constraints for which you want to retrieve the referred variables. The function returns a subset of the set AllVariables, containing the variables found. See also: The function VariableConstraints.

10 Set Related Functions 48 Element With the function Element you can retrieve then-th element from a set. Element( Set, n! (input set reference! (input integer expression Set n The set from which an element is to be returned. An integer expression indicating the ordinal number of the element to be returned. The function Element returns then-th element of set Set. Remarks: If there is non-th element in Set, the function returns the empty element instead.

11 Set Related Functions 49 ElementCast With the function ElementCast you can cast an element of one set to an (existing element with the same name in a set with a different root set. ElementCast( set,! (input a set expression element,! (input a scalar element expression [create]! (optional 0 or 1 set A set in which you want to find a specific element name. element A scalar element expression, representing the element that you want to convert to a different root set hierarchy. create (optional An indicator whether or not a nonexisting element are added to the set during the call. The function returns the existing element or, if the element cannot be converted to an existing element and the argument create is not set to 1, the function returns the empty element. If create is set to 1, nonexisting elements will be created on the fly. See also: The procedure SetElementAdd.

12 Set Related Functions 50 ElementRange With the function ElementRange you can create a set with elements in which each element can be constructed using a prefix string, a postfix string, and a a sequential number. ElementRange( from,! (input integer expression to,! (input integer expression [incr,]! (optional integer expression [prefix,]! (optional string expression [postfix,]! (optional string expression [fill]! (optional 0 or 1 from The integer value for which the first element must be created to The integer value for which the last element must be created incr (optional The integer-valued interval length between two consecutive elements. If omitted, then the default interval length of 1 is used. prefix (optional The prefix string for every element. If omitted, then the elements have no prefix (and thus start with the number. postfix (optional The postfix string for every element. If omitted, then the elements have no postfix (and thus end with the number. fill (optional This logical indicator specifies whether the numbers must be padded with leading zeroes. If omitted, then the default value 1 is used. The function returns a set containing the created elements.

13 Set Related Functions 51 FindUsedElements The procedure FindUsedElements finds all elements of a particular set that are in use in a given collection of indexed model identifiers. FindUsedElements( SearchSet,! (input a set SearchIdentifiers,! (input a subset of AllIdentifiers UsedElements! (output a subset SearchSet The set for which you want to find the used elements. SearchIdentifiers A subset of AllIdentifiers, holding identifiers that are indexed over SearchSet. UsedElements A subset of SearchSet. On return this subset will contain the elements that are currently used (i.e. have corresponding nondefault values in the identifiers contained in SearchIdentifiers.

14 Set Related Functions 52 First With the function First you can retrieve the first element from a set. First( Set,! (input set reference Set The set from which the first element is to be returned. The function First returns the first element of set Set. Remarks: If there is no element in Set, the function returns the empty element instead.

15 Set Related Functions 53 Last With the function Last you can retrieve the last element from a set. Last( Set,! (input set reference Set The set from which the last element is to be returned. The function Last returns the last element of set Set. Remarks: If there is no element in Set, the function returns the empty element instead.

16 Set Related Functions 54 Ord The function Ord returns the ordinal number of a set element relative to a set. Ord( index, [set]! (input element expression! (optional set reference index An element expression for which you want to obtain the ordinal number. set (optional The set with respect to which you want the ordinal number to be taken. If omitted, set is assumed to be the range of the argument index. The function Ord returns the ordinal number of index in set set. Remarks: A compile time error occurs if the argument set is not present, and Aimms is unable to determine the range of index.

17 Set Related Functions 55 RestoreInactiveElements The procedure RestoreInactiveElements finds and restores all elements that were previously removed from a particular set, but for which inactive data still exists in a given collection of indexed model identifiers. RestoreInactiveElements( SearchSet,! (input/output a set SearchIdentifiers,! (input a subset of AllIdentifiers UsedElements! (output a subset SearchSet The set for which you want to find the inactive elements. SearchIdentifiers A subset of AllIdentifiers, holding identifiers that are indexed over SearchSet. UsedElements A subset of SearchSet. On return this subset will contain all the inactive elements that are currently used (i.e. have corresponding nondefault values in the identifiers contained in SearchIdentifiers. Remarks: The inactive elements found are placed in the result-set, but are also automatically added to the search-set.

18 Set Related Functions 56 RetrieveCurrentVariableValues With the procedure RetrieveCurrentVariableValues you can obtain the variable values for a given collection of variables during a running solution process. This procedure can only be called from within the context of a solver callback procedure. RetrieveCurrentVariableValues( Variables! (input a subset of AllVariables Variables A subset of AllVariables, holding all the variables for which you want to retrieve the current values. See also: Solver callback procedures are discussed in full detail in Section 15.2 of the Language Reference

19 Set Related Functions 57 SetAddRecursive With the procedure SetAddRecursive you can merge the elements of one set into another set. SetAddRecursive( toset, fromset! (input/output a set! (input a set toset The set into which the elements of fromset are merged. fromset The set that you want to merge in toset. Remarks: The sets toset and fromset should have the same root set. The difference between this function and a regular set assignment is that in case fromset is not the domain of toset all elements added to toset will also be added to the domain set of toset

20 Set Related Functions 58 SetElementAdd With the procedure SetElementAdd you can add new elements to a set. When you apply SetElementAdd to a root set, the element will be added to that root set. When you apply it to a subset, the element will be added to the subset as well as to all its supersets, up to and including its associated root set. SetElementAdd( Setname,! (input/output a set Elempar,! (output an element parameter Newname! (input a scalar string expression Setname The root set or subset to which you want to add the element. Elempar An element parameter into Setname, that on return will point to the newly added element. Newname A string holding the name of the element to be added. Remarks: If the element already exists in the set, the procedure does not make any changes to the set, and on return the element parameter Elempar will point to the existing element. See also: The functionelementcast and the proceduressetelementrename andstringtoelement. The lexical conventions for set elements in Section 2.3 of the Language Reference.

21 Set Related Functions 59 SetElementRename With the procedure SetElementRename you can rename an element in a set. SetElementRename( Setname, Element, Newname! (input a set! (input an element parameter! (input a scalar string expression Setname The root set or subset in which you want to rename an element. Element The element that you want to rename. Newname A string holding the new name of the element. Remarks: If the new name for the element already exists in the set, the procedure will generate an execution error. Aimms will refuse to rename a set element, if an explicit reference to such an element exists in the model source. See also: The procedure SetElementAdd, and the function StringToElement. The lexical conventions for set elements in Section 2.3 of the Language Reference.

22 Set Related Functions 60 StringToElement With the function StringToElement you can convert a string into an (existing element of a set. StringToElement( Set,! (input a set expression Name,! (input a scalar string [create]! (optional 0 or 1, default 0 Set A set in which you want to find a specific element name. Name A scalar string expression, representing the string that you want to convert. create (optional An indicator whether or not a nonexisting element are added to the set during the call. The function returns the existing element or, if the string cannot be converted to an existing element and the argument create is not set to 1, the function return the empty element. If create is set to 1, nonexisting elements will be created on the fly. See also: The function ElementCast and the procedure SetElementAdd. The lexical conventions for set elements in Section 2.3 of the Language Reference.

23 Set Related Functions 61 SubRange The function SubRange extracts a subrange of consecutive elements from an existing set. SubRange( Superset, First, Last! (input a simple or compound set! (input an element! (input an element Superset The set containing the subrange of elements that you want to extract. First An element in Superset representing the first element of the subrange. Last An element in Superset representing the last element of the subrange. The function returns a set containing the subrange of elements extracted from Superset. If the element First is positioned after Last, then the empty set is returned.

24 Set Related Functions 62 VariableConstraints The function VariableConstraints returns all the symbolic constraints that refer to one or more variables in a given set of variables. VariableConstraints( Variables! (input a subset of AllVariables Variables The set of variables for which you want to retrieve the constraints that refer to them. This is a subset of AllVariables. The function returns a subset of the set AllConstraints, containing the constraints found. See also: The function ConstraintVariables.

AIMMS Function Reference - Data Change Monitor Functions This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com Aimms 3.13 Data

AIMMS Tutorial for Professionals - Quantities and Time This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com Aimms 3.13 Copyright

AIMMS Function Reference - Arithmetic Functions This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com Aimms 3.13 Part I Function

Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

9 Specifying Data As 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

PL/SQL Overview PL/SQL is Procedural Language extension to SQL. It is loosely based on Ada (a variant of Pascal developed for the US Dept of Defense). PL/SQL was first released in ١٩٩٢ as an optional extension

Lab 2 : Basic File Server Introduction In this lab, you will start your file system implementation by getting the following FUSE operations to work: CREATE/MKNOD, LOOKUP, and READDIR SETATTR, WRITE and

Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

AIMMS Tutorial for Professionals - Absentee and Planning Overviews This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com Aimms

1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the

The NewSQL database you ll never outgrow Integrating with Hadoop Hadoop is an open source framework for managing and manipulating massive volumes of data. is an database for handling high velocity data.

Coveo Platform 7.0 Microsoft Dynamics CRM Connector Guide Notice The content in this document represents the current view of Coveo as of the date of publication. Because Coveo continually responds to changing

Introduction Table of Contents About This Course...i Who Should Attend this Course...i How to Use this Book... ii Conventions Used in this Book... ii Lesson 1 Introduction to Object-Oriented Approach Object-Oriented

APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated

13 Command Scripts You will probably find that your most intensive use of AMPL s command environment occurs during the initial development of a model, when the results are unfamiliar and changes are frequent.

Name: Date: Block: Functions: Review What is a.? Relation: Function: Domain: Range: Draw a graph of a : a) relation that is a function b) relation that is NOT a function Function Notation f(x): Names the

Data Structure Lecture 3 Data Structure Formally define Data structure as: DS describes not only set of objects but the ways they are related, the set of operations which may be applied to the elements

AIMMS Language Reference - Format of Text Data Files This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com or order your hardcopy

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

10 Database Access The structure of indexed data in AMPL has much in common with the structure of the relational tables widely used in database applications. The AMPL table declaration lets you take advantage

LabVIEW Day 3: Arrays and Clusters Vern Lindberg By now you should be getting used to LabVIEW. You should know how to Create a Constant, Control, or Indicator. I will assume you know how to create a new

Data mining knowledge representation 1 What Defines a Data Mining Task? Task relevant data: where and how to retrieve the data to be used for mining Background knowledge: Concept hierarchies Interestingness

Debugging Complex Macros Peter Stagg, Decision Informatics It s possible to write code generated by macros to an external file. The file can t be access until the SAS session has ended. Use the options

Physical Design Physical Database Design (Defined): Process of producing a description of the implementation of the database on secondary storage; it describes the base relations, file organizations, and

MicroStrategy Quick Guide: Creating Prompts ITU Data Mart Support Group, Reporting Services Prompts Prompts are questions the report user must answer in order to run the report. Some prompts are required

MS ACCESS - INTRODUCTION MS Access is an example of a relational database. It allows to build and maintain small and medium-sized databases and to supply them with a graphical user interface. The aim of

WP. 2 ENGLISH ONLY UNITED NATIONS STATISTICAL COMMISSION and ECONOMIC COMMISSION FOR EUROPE CONFERENCE OF EUROPEAN STATISTICIANS Work Session on Statistical Data Editing (Bonn, Germany, 25-27 September

Coveo Platform 7.0 Oracle Knowledge Connector Guide Notice The content in this document represents the current view of Coveo as of the date of publication. Because Coveo continually responds to changing

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I

MATH 337 Cardinality Dr. Neal, WKU We now shall prove that the rational numbers are a countable set while R is uncountable. This result shows that there are two different magnitudes of infinity. But we

CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY 2.1 Introduction In this chapter, I am going to introduce Database Management Systems (DBMS) and the Structured Query Language (SQL), its syntax and usage.

Oracle University Contact Us: 1.800.529.0165 Oracle Database: Introduction to SQL Duration: 5 Days What you will learn View a newer version of this course This Oracle Database: Introduction to SQL training

AIMMS User s Guide - Case Management This file contains only one chapter of the book. For a free download of the complete book in pdf format, please visit www.aimms.com or order your hardcopy at www.lulu.com/aimms.

Sets and Subsets Countable and Uncountable Reading Appendix A Section A.6.8 Pages 788-792 BIG IDEAS Themes 1. There exist functions that cannot be computed in Java or any other computer language. 2. There

PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

IOE Library Guide EndNote Cite While You Write FAQs We have compiled a list of the more frequently asked questions and answers about citing your references in Word and working with EndNote libraries (desktop

CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to help you to better understand functions:

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with the basic components of a C++ program,

Creating a Guest Book Using WebObjects Builder Creating a Guest Book Using WebObjects BuilderLaunch WebObjects Builder WebObjects Builder is an application that helps you create WebObjects applications.