text
stringlengths
1
1k
source
stringlengths
31
152
elopment and maintenance costs. === Modularity and scoping === Modularity is about organizing the procedures of a program into separate modules—each of which has a specific and understandable purpose. Minimizing the scope of variables and procedures can enhance software quality by reducing the cognitive load of procedures and modules. A program lacking modularity or wide scoping tends to have procedures that consume many variables that other procedures also consume. The resulting code is relatively hard to understand and to maintain. === Sharing === Since a procedure can specify a well-defined interface and be self-contained it supports code reuse—in particular via the software library. == Comparison with other programming paradigms == === Imperative programming === Procedural programming is classified as an imperative programming, because it involves direct command of execution. Procedural is a sub-class of imperative since procedural includes block and scope concepts, whereas
https://en.wikipedia.org/wiki/Procedural_programming
cedural includes block and scope concepts, whereas imperative describes a more general concept that does not require such features. Procedural languages generally use reserved words that define blocks, such as if, while, and for, to implement control flow, whereas non-structured imperative languages (i.e. assembly language) use goto and branch tables for this purpose. === Object-oriented programming === Also classified as imperative, object-oriented programming (OOP) involves dividing a program implementation into objects that expose behavior (methods) and data (members) via a well-defined interface. In contrast, procedural programming is about dividing the program implementation into variables, data structures, and subroutines. An important distinction is that while procedural involves procedures to operate on data structures, OOP bundles the two together. An object is a data structure and the behavior associated with that data structure. Some OOP languages support the class concept
https://en.wikipedia.org/wiki/Procedural_programming
ture. Some OOP languages support the class concept which allows for creating an object based on a definition. Nomenclature varies between the two, although they have similar semantics: === Functional programming === The principles of modularity and code reuse in functional languages are fundamentally the same as in procedural languages, since they both stem from structured programming. For example: Procedures correspond to functions. Both allow the reuse of the same code in various parts of the programs, and at various points of its execution. By the same token, procedure calls correspond to function application. Functions and their modularly separated from each other in the same manner, by the use of function arguments, return values and variable scopes. The main difference between the styles is that functional programming languages remove or at least deemphasize the imperative elements of procedural programming. The feature set of functional languages is therefore designed to su
https://en.wikipedia.org/wiki/Procedural_programming
f functional languages is therefore designed to support writing programs as much as possible in terms of pure functions: Whereas procedural languages model execution of the program as a sequence of imperative commands that may implicitly alter shared state, functional programming languages model execution as the evaluation of complex expressions that only depend on each other in terms of arguments and return values. For this reason, functional programs can have a free order of code execution, and the languages may offer little control over the order in which various parts of the program are executed; for example, the arguments to a procedure invocation in Scheme are evaluated in an arbitrary order. Functional programming languages support (and heavily use) first-class functions, anonymous functions and closures, although these concepts have also been included in procedural languages at least since Algol 68. Functional programming languages tend to rely on tail call optimization and h
https://en.wikipedia.org/wiki/Procedural_programming
uages tend to rely on tail call optimization and higher-order functions instead of imperative looping constructs. Many functional languages, however, are in fact impurely functional and offer imperative/procedural constructs that allow the programmer to write programs in procedural style, or in a combination of both styles. It is common for input/output code in functional languages to be written in a procedural style. There do exist a few esoteric functional languages (like Unlambda) that eschew structured programming precepts for the sake of being difficult to program in (and therefore challenging). These languages are the exception to the common ground between procedural and functional languages. === Logic programming === In logic programming, a program is a set of premises, and computation is performed by attempting to prove candidate theorems. From this point of view, logic programs are declarative, focusing on what the problem is, rather than on how to solve it. However, the b
https://en.wikipedia.org/wiki/Procedural_programming
is, rather than on how to solve it. However, the backward reasoning technique, implemented by SLD resolution, used to solve problems in logic programming languages such as Prolog, treats programs as goal-reduction procedures. Thus clauses of the form: H :- B1, …, Bn. have a dual interpretation, both as procedures to show/solve H, show/solve B1 and … and Bn and as logical implications: B1 and … and Bn implies H. A skilled logic programmer uses the procedural interpretation to write programs that are effective and efficient, and uses the declarative interpretation to help ensure that programs are correct. == See also == Declarative programming Functional programming (contrast) Imperative programming Logic programming Object-oriented programming Programming paradigms Programming language Structured programming SQL procedural extensions == References == == External links ==
https://en.wikipedia.org/wiki/Procedural_programming
Goal programming is a branch of multiobjective optimization, which in turn is a branch of multi-criteria decision analysis (MCDA). It can be thought of as an extension or generalisation of linear programming to handle multiple, normally conflicting objective measures. Each of these measures is given a goal or target value to be achieved. Deviations are measured from these goals both above and below the target. Unwanted deviations from this set of target values are then minimised in an achievement function. This can be a vector or a weighted sum dependent on the goal programming variant used. As satisfaction of the target is deemed to satisfy the decision maker(s), an underlying satisficing philosophy is assumed. Goal programming is used to perform three types of analysis: Determine the required resources to achieve a desired set of objectives. Determine the degree of attainment of the goals with the available resources. Providing the best satisfying solution under a varying amount of
https://en.wikipedia.org/wiki/Goal_programming
est satisfying solution under a varying amount of resources and priorities of the goals. == History == Goal programming was first used by Charnes, Cooper and Ferguson in 1955, although the actual name first appeared in a 1961 text by Charnes and Cooper. Seminal works by Lee, Ignizio, Ignizio and Cavalier, and Romero followed. Schniederjans gives in a bibliography of a large number of pre-1995 articles relating to goal programming, and Jones and Tamiz give an annotated bibliography of the period 1990-2000. A recent textbook by Jones and Tamiz . gives a comprehensive overview of the state-of-the-art in goal programming. The first engineering application of goal programming, due to Ignizio in 1962, was the design and placement of the antennas employed on the second stage of the Saturn V. This was used to launch the Apollo space capsule that landed the first men on the moon. == Variants == The initial goal programming formulations ordered the unwanted deviations into a number of prior
https://en.wikipedia.org/wiki/Goal_programming
red the unwanted deviations into a number of priority levels, with the minimisation of a deviation in a higher priority level being infinitely more important than any deviations in lower priority levels. This is known as lexicographic or pre-emptive goal programming. Ignizio gives an algorithm showing how a lexicographic goal programme can be solved as a series of linear programmes. Lexicographic goal programming is used when there exists a clear priority ordering amongst the goals to be achieved. If the decision maker is more interested in direct comparisons of the objectives then weighted or non-pre-emptive goal programming should be used. In this case, all the unwanted deviations are multiplied by weights, reflecting their relative importance, and added together as a single sum to form the achievement function. Deviations measured in different units cannot be summed directly due to the phenomenon of incommensurability. Hence each unwanted deviation is multiplied by a normalisation
https://en.wikipedia.org/wiki/Goal_programming
nwanted deviation is multiplied by a normalisation constant to allow direct comparison. Popular choices for normalisation constants are the goal target value of the corresponding objective (hence turning all deviations into percentages) or the range of the corresponding objective (between the best and the worst possible values, hence mapping all deviations onto a zero-one range). For decision makers more interested in obtaining a balance between the competing objectives, Chebyshev goal programming is used. Introduced by Flavell in 1976, this variant seeks to minimise the maximum unwanted deviation, rather than the sum of deviations. This utilises the Chebyshev distance metric. == Strengths and weaknesses == A major strength of goal programming is its simplicity and ease of use. This accounts for the large number of goal programming applications in many and diverse fields. Linear goal programmes can be solved using linear programming software as either a single linear programme, or in
https://en.wikipedia.org/wiki/Goal_programming
oftware as either a single linear programme, or in the case of the lexicographic variant, a series of connected linear programmes. Goal programming can hence handle relatively large numbers of variables, constraints and objectives. A debated weakness is the ability of goal programming to produce solutions that are not Pareto efficient. This violates a fundamental concept of decision theory, that no rational decision maker will knowingly choose a solution that is not Pareto efficient. However, techniques are available to detect when this occurs and project the solution onto the Pareto efficient solution in an appropriate manner. The setting of appropriate weights in the goal programming model is another area that has caused debate, with some authors suggesting the use of the analytic hierarchy process or interactive methods for this purpose. Also, the weights of the objective functions can be calculated based on their preference using the ordinal priority approach. == See also == Dec
https://en.wikipedia.org/wiki/Goal_programming
he ordinal priority approach. == See also == Decision-making software == External links == LiPS — Free easy-to-use GUI program intended for solving linear, integer and goal programming problems. LINSOLVE - Free Windows command-line window linear programming and linear goal programming] == References ==
https://en.wikipedia.org/wiki/Goal_programming
In computer programming, initialization or initialisation is the assignment of an initial value for a data object or variable. The manner in which initialization is performed depends on the programming language, as well as the type, storage class, etc., of an object to be initialized. Programming constructs which perform initialization are typically called initializers and initializer lists. Initialization is distinct from (and preceded by) declaration, although the two can sometimes be conflated in practice. The complement of initialization is finalization, which is primarily used for objects, but not variables. Initialization is done either by statically embedding the value at compile time, or else by assignment at run time. A section of code that performs such initialization is generally known as "initialization code" and may include other, one-time-only, functions such as opening files; in object-oriented programming, initialization code may be part of a constructor (class method)
https://en.wikipedia.org/wiki/Initialization_(programming)
code may be part of a constructor (class method) or an initializer (instance method). Setting a memory location to hexadecimal zeroes is also sometimes known as "clearing" and is often performed by an exclusive or instruction (both operands specifying the same variable), at machine code level, since it requires no additional memory access. == C family of languages == === Initializer === In C/C99/C++, an initializer is an optional part of a declarator. It consists of the '=' character followed by an expression or a comma-separated list of expressions placed in curly brackets (braces). The latter list is sometimes called the "initializer list" or "initialization list" (although the term "initializer list" is formally reserved for initialization of class/struct members in C++; see below). A declaration which creates a data object, instead of merely describing its existence, is commonly called a definition. Many find it convenient to draw a distinction between the terms "declaration"
https://en.wikipedia.org/wiki/Initialization_(programming)
raw a distinction between the terms "declaration" and "definition", as in the commonly seen phrase "the distinction between a declaration and definition...", implying that a declaration merely designates a data object (or function). In fact, according to the C++ standard, a definition is a declaration. Still, the usage "declarations and definitions", although formally incorrect, is common. Although all definitions are declarations, not all declarations are definitions. C examples: C++ examples: === Initializer list === In C++, a constructor of a class/struct can have an initializer list within the definition but prior to the constructor body. It is important to note that when you use an initialization list, the values are not assigned to the variable. They are initialized. In the below example, 0 is initialized into re and im. Example: Here, the construct : re(0), im(0) is the initializer list. Sometimes the term "initializer list" is also used to refer to the list of expressions
https://en.wikipedia.org/wiki/Initialization_(programming)
" is also used to refer to the list of expressions in the array or struct initializer. C++11 provides for a more powerful concept of initializer lists, by means of a template, called std::initializer_list. === Default initialization === Data initialization may occur without explicit syntax in a program to do so. For example, if static variables are declared without an initializer, then those of primitive data types are initialized with the value of zero of the corresponding type, while static objects of class type are initialized with their default constructors. == See also == Object lifetime Finalizer Process & related Finalization Pattern == References ==
https://en.wikipedia.org/wiki/Initialization_(programming)
Linear programming (LP), also called linear optimization, is a method to achieve the best outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements and objective are represented by linear relationships. Linear programming is a special case of mathematical programming (also known as mathematical optimization). More formally, linear programming is a technique for the optimization of a linear objective function, subject to linear equality and linear inequality constraints. Its feasible region is a convex polytope, which is a set defined as the intersection of finitely many half spaces, each of which is defined by a linear inequality. Its objective function is a real-valued affine (linear) function defined on this polytope. A linear programming algorithm finds a point in the polytope where this function has the largest (or smallest) value if such a point exists. Linear programs are problems that can be expressed in standard form as:
https://en.wikipedia.org/wiki/Linear_programming
ssed in standard form as: Find a vector x that maximizes c T x subject to A x ≤
https://en.wikipedia.org/wiki/Linear_programming
≤ b and x ≥ 0 . {\displaystyle {\begin{aligned}&{\text{Find a vector}}&&\mathbf {x} \\&{\text{that maximizes}}&&\mathbf {c} ^{\mathsf {T}}\mathbf {x} \\&{\text{subject to}}&&A\mathbf {x} \leq \mathbf {b} \\&{\text{and}}&&\mathbf {x} \geq \mathbf {0} .\end{aligned}}} Here the components of x {\displaystyle \mathbf {x} } are the variables to be determined, c {\displaystyle \mathbf {c} } and
https://en.wikipedia.org/wiki/Linear_programming
f {c} } and b {\displaystyle \mathbf {b} } are given vectors, and A {\displaystyle A} is a given matrix. The function whose value is to be maximized ( x ↦ c T x {\displaystyle \mathbf {x} \mapsto \mathbf {c} ^{\mathsf {T}}\mathbf {x} } in this case) is called the objective function. The constraints A x ≤ b {\displaystyle A\mathbf {x} \leq \mathbf {b} } and x ≥ 0 {\displaystyle \mathbf {x} \geq \mathbf {0} } specify a convex polytope over which the objective funct
https://en.wikipedia.org/wiki/Linear_programming
y a convex polytope over which the objective function is to be optimized. Linear programming can be applied to various fields of study. It is widely used in mathematics and, to a lesser extent, in business, economics, and some engineering problems. There is a close connection between linear programs, eigenequations, John von Neumann's general equilibrium model, and structural equilibrium models (see dual linear program for details). Industries that use linear programming models include transportation, energy, telecommunications, and manufacturing. It has proven useful in modeling diverse types of problems in planning, routing, scheduling, assignment, and design. == History == The problem of solving a system of linear inequalities dates back at least as far as Fourier, who in 1827 published a method for solving them, and after whom the method of Fourier–Motzkin elimination is named. In the late 1930s, Soviet mathematician Leonid Kantorovich and American economist Wassily Leontief in
https://en.wikipedia.org/wiki/Linear_programming
orovich and American economist Wassily Leontief independently delved into the practical applications of linear programming. Kantorovich focused on manufacturing schedules, while Leontief explored economic applications. Their groundbreaking work was largely overlooked for decades. The turning point came during World War II when linear programming emerged as a vital tool. It found extensive use in addressing complex wartime challenges, including transportation logistics, scheduling, and resource allocation. Linear programming proved invaluable in optimizing these processes while considering critical constraints such as costs and resource availability. Despite its initial obscurity, the wartime successes propelled linear programming into the spotlight. Post-WWII, the method gained widespread recognition and became a cornerstone in various fields, from operations research to economics. The overlooked contributions of Kantorovich and Leontief in the late 1930s eventually became foundational
https://en.wikipedia.org/wiki/Linear_programming
f in the late 1930s eventually became foundational to the broader acceptance and utilization of linear programming in optimizing decision-making processes. Kantorovich's work was initially neglected in the USSR. About the same time as Kantorovich, the Dutch-American economist T. C. Koopmans formulated classical economic problems as linear programs. Kantorovich and Koopmans later shared the 1975 Nobel Memorial Prize in Economic Sciences. In 1941, Frank Lauren Hitchcock also formulated transportation problems as linear programs and gave a solution very similar to the later simplex method. Hitchcock had died in 1957, and the Nobel Memorial Prize is not awarded posthumously. From 1946 to 1947 George B. Dantzig independently developed general linear programming formulation to use for planning problems in the US Air Force. In 1947, Dantzig also invented the simplex method that, for the first time efficiently, tackled the linear programming problem in most cases. When Dantzig arranged a meeti
https://en.wikipedia.org/wiki/Linear_programming
oblem in most cases. When Dantzig arranged a meeting with John von Neumann to discuss his simplex method, von Neumann immediately conjectured the theory of duality by realizing that the problem he had been working in game theory was equivalent. Dantzig provided formal proof in an unpublished report "A Theorem on Linear Inequalities" on January 5, 1948. Dantzig's work was made available to public in 1951. In the post-war years, many industries applied it in their daily planning. Dantzig's original example was to find the best assignment of 70 people to 70 jobs. The computing power required to test all the permutations to select the best assignment is vast; the number of possible configurations exceeds the number of particles in the observable universe. However, it takes only a moment to find the optimum solution by posing the problem as a linear program and applying the simplex algorithm. The theory behind linear programming drastically reduces the number of possible solutions that must
https://en.wikipedia.org/wiki/Linear_programming
reduces the number of possible solutions that must be checked. The linear programming problem was first shown to be solvable in polynomial time by Leonid Khachiyan in 1979, but a larger theoretical and practical breakthrough in the field came in 1984 when Narendra Karmarkar introduced a new interior-point method for solving linear-programming problems. == Uses == Linear programming is a widely used field of optimization for several reasons. Many practical problems in operations research can be expressed as linear programming problems. Certain special cases of linear programming, such as network flow problems and multicommodity flow problems, are considered important enough to have much research on specialized algorithms. A number of algorithms for other types of optimization problems work by solving linear programming problems as sub-problems. Historically, ideas from linear programming have inspired many of the central concepts of optimization theory, such as duality, decomposition,
https://en.wikipedia.org/wiki/Linear_programming
timization theory, such as duality, decomposition, and the importance of convexity and its generalizations. Likewise, linear programming was heavily used in the early formation of microeconomics, and it is currently utilized in company management, such as planning, production, transportation, and technology. Although the modern management issues are ever-changing, most companies would like to maximize profits and minimize costs with limited resources. Google also uses linear programming to stabilize YouTube videos. == Standard form == Standard form is the usual and most intuitive form of describing a linear programming problem. It consists of the following three parts: A linear (or affine) function to be maximized e.g. f ( x 1 , x 2 ) = c 1
https://en.wikipedia.org/wiki/Linear_programming
1 x 1 + c 2 x 2 {\displaystyle f(x_{1},x_{2})=c_{1}x_{1}+c_{2}x_{2}} Problem constraints of the following form e.g. a 11 x 1 + a 12 x 2 ≤ b
https://en.wikipedia.org/wiki/Linear_programming
≤ b 1 a 21 x 1 + a 22 x 2 ≤ b 2 a 31
https://en.wikipedia.org/wiki/Linear_programming
31 x 1 + a 32 x 2 ≤ b 3 {\displaystyle {\begin{matrix}a_{11}x_{1}+a_{12}x_{2}&\leq b_{1}\\a_{21}x_{1}+a_{22}x_{2}&\leq b_{2}\\a_{31}x_{1}+a_{32}x_{2}&\leq b_{3}\\\end{matrix}}} Non-negative variables e.g. x 1
https://en.wikipedia.org/wiki/Linear_programming
1 ≥ 0 x 2 ≥ 0 {\displaystyle {\begin{matrix}x_{1}\geq 0\\x_{2}\geq 0\end{matrix}}} The problem is usually expressed in matrix form, and then becomes: max { c T x ∣ x ∈ R n ∧ A x ≤ b ∧ x ≥ 0 }
https://en.wikipedia.org/wiki/Linear_programming
≥ 0 } {\displaystyle \max\{\,\mathbf {c} ^{\mathsf {T}}\mathbf {x} \mid \mathbf {x} \in \mathbb {R} ^{n}\land A\mathbf {x} \leq \mathbf {b} \land \mathbf {x} \geq 0\,\}} Other forms, such as minimization problems, problems with constraints on alternative forms, and problems involving negative variables can always be rewritten into an equivalent problem in standard form. === Example === Suppose that a farmer has a piece of farm land, say L hectares, to be planted with either wheat or barley or some combination of the two. The farmer has F kilograms of fertilizer and P kilograms of pesticide. Every hectare of wheat requires F1 kilograms of fertilizer and P1 kilograms of pesticide, while every hectare of barley requires F2 kilograms of fertilizer and P2 kilograms of pesticide. Let S1 be the selling price of wheat and S2 be the selling price of barley, per hectare. If we denote the area of land planted with wheat and barley by x1 an
https://en.wikipedia.org/wiki/Linear_programming
rea of land planted with wheat and barley by x1 and x2 respectively, then profit can be maximized by choosing optimal values for x1 and x2. This problem can be expressed with the following linear programming problem in the standard form: In matrix form this becomes: maximize [ S 1 S 2 ] [ x 1
https://en.wikipedia.org/wiki/Linear_programming
x 2 ] {\displaystyle {\begin{bmatrix}S_{1}&S_{2}\end{bmatrix}}{\begin{bmatrix}x_{1}\\x_{2}\end{bmatrix}}} subject to [ 1 1 F 1 F 2
https://en.wikipedia.org/wiki/Linear_programming
P 1 P 2 ] [ x 1 x 2 ] ≤ [ L
https://en.wikipedia.org/wiki/Linear_programming
L F P ] , [ x 1 x 2 ] ≥ [ 0 0
https://en.wikipedia.org/wiki/Linear_programming
0 ] . {\displaystyle {\begin{bmatrix}1&1\\F_{1}&F_{2}\\P_{1}&P_{2}\end{bmatrix}}{\begin{bmatrix}x_{1}\\x_{2}\end{bmatrix}}\leq {\begin{bmatrix}L\\F\\P\end{bmatrix}},\,{\begin{bmatrix}x_{1}\\x_{2}\end{bmatrix}}\geq {\begin{bmatrix}0\\0\end{bmatrix}}.} == Augmented form (slack form) == Linear programming problems can be converted into an augmented form in order to apply the common form of the simplex algorithm. This form introduces non-negative slack variables to replace inequalities with equalities in the constraints. The problems can then be written in the following block matrix form: Maximize z {\displaystyle z} : [ 1 −
https://en.wikipedia.org/wiki/Linear_programming
c T 0 0 A I ] [ z x s
https://en.wikipedia.org/wiki/Linear_programming
] = [ 0 b ] {\displaystyle {\begin{bmatrix}1&-\mathbf {c} ^{\mathsf {T}}&0\\0&\mathbf {A} &\mathbf {I} \end{bmatrix}}{\begin{bmatrix}z\\\mathbf {x} \\\mathbf {s} \end{bmatrix}}={\begin{bmatrix}0\\\mathbf {b} \end{bmatrix}}} x ≥ 0 , s ≥ 0 {\displaystyle \mathbf {x} \geq 0,\mathbf {s} \geq 0} where s {\displaystyle \mathbf {s} } are the newly introduced slack variables,
https://en.wikipedia.org/wiki/Linear_programming
wly introduced slack variables, x {\displaystyle \mathbf {x} } are the decision variables, and z {\displaystyle z} is the variable to be maximized. === Example === The example above is converted into the following augmented form: where x 3 , x 4 , x 5 {\displaystyle x_{3},x_{4},x_{5}} are (non-negative) slack variables, representing in this example the unused area, the amount of unused fertilizer, and the amount of unused pesticide. In matrix form this becomes: Maximize z {\displaystyle z} : [
https://en.wikipedia.org/wiki/Linear_programming
1 − S 1 − S 2 0 0 0 0 1 1 1 0 0
https://en.wikipedia.org/wiki/Linear_programming
0 F 1 F 2 0 1 0 0 P 1 P 2
https://en.wikipedia.org/wiki/Linear_programming
0 0 1 ] [ z x 1 x 2 x 3
https://en.wikipedia.org/wiki/Linear_programming
x 4 x 5 ] = [ 0 L F P ] , [ x
https://en.wikipedia.org/wiki/Linear_programming
x 1 x 2 x 3 x 4 x 5 ] ≥ 0.
https://en.wikipedia.org/wiki/Linear_programming
] ≥ 0. {\displaystyle {\begin{bmatrix}1&-S_{1}&-S_{2}&0&0&0\\0&1&1&1&0&0\\0&F_{1}&F_{2}&0&1&0\\0&P_{1}&P_{2}&0&0&1\\\end{bmatrix}}{\begin{bmatrix}z\\x_{1}\\x_{2}\\x_{3}\\x_{4}\\x_{5}\end{bmatrix}}={\begin{bmatrix}0\\L\\F\\P\end{bmatrix}},\,{\begin{bmatrix}x_{1}\\x_{2}\\x_{3}\\x_{4}\\x_{5}\end{bmatrix}}\geq 0.} == Duality == Every linear programming problem, referred to as a primal problem, can be converted into a dual problem, which provides an upper bound to the optimal value of the primal problem. In matrix form, we can express the primal problem as: Maximize cTx subject to Ax ≤ b, x ≥ 0; with the corresponding symmetric dual problem, Minimize bTy subject to ATy ≥ c, y ≥ 0. An alternative primal formulation is: Maximize cTx subject to Ax ≤ b; with the corresponding asymmetric dual problem, Minimize bTy subject to ATy = c, y ≥ 0. There are two ideas fundamental to duality theory. One is the fact that (for the symmetric d
https://en.wikipedia.org/wiki/Linear_programming
theory. One is the fact that (for the symmetric dual) the dual of a dual linear program is the original primal linear program. Additionally, every feasible solution for a linear program gives a bound on the optimal value of the objective function of its dual. The weak duality theorem states that the objective function value of the dual at any feasible solution is always greater than or equal to the objective function value of the primal at any feasible solution. The strong duality theorem states that if the primal has an optimal solution, x*, then the dual also has an optimal solution, y*, and cTx*=bTy*. A linear program can also be unbounded or infeasible. Duality theory tells us that if the primal is unbounded then the dual is infeasible by the weak duality theorem. Likewise, if the dual is unbounded, then the primal must be infeasible. However, it is possible for both the dual and the primal to be infeasible. See dual linear program for details and several more examples. == Var
https://en.wikipedia.org/wiki/Linear_programming
am for details and several more examples. == Variations == === Covering/packing dualities === A covering LP is a linear program of the form: Minimize: bTy, subject to: ATy ≥ c, y ≥ 0, such that the matrix A and the vectors b and c are non-negative. The dual of a covering LP is a packing LP, a linear program of the form: Maximize: cTx, subject to: Ax ≤ b, x ≥ 0, such that the matrix A and the vectors b and c are non-negative. ==== Examples ==== Covering and packing LPs commonly arise as a linear programming relaxation of a combinatorial problem and are important in the study of approximation algorithms. For example, the LP relaxations of the set packing problem, the independent set problem, and the matching problem are packing LPs. The LP relaxations of the set cover problem, the vertex cover problem, and the dominating set problem are also covering LPs. Finding a fractional coloring of a graph is another example of a covering LP. In this case, there is one constraint for each
https://en.wikipedia.org/wiki/Linear_programming
LP. In this case, there is one constraint for each vertex of the graph and one variable for each independent set of the graph. == Complementary slackness == It is possible to obtain an optimal solution to the dual when only an optimal solution to the primal is known using the complementary slackness theorem. The theorem states: Suppose that x = (x1, x2, ... , xn) is primal feasible and that y = (y1, y2, ... , ym) is dual feasible. Let (w1, w2, ..., wm) denote the corresponding primal slack variables, and let (z1, z2, ... , zn) denote the corresponding dual slack variables. Then x and y are optimal for their respective problems if and only if xj zj = 0, for j = 1, 2, ... , n, and wi yi = 0, for i = 1, 2, ... , m. So if the i-th slack variable of the primal is not zero, then the i-th variable of the dual is equal to zero. Likewise, if the j-th slack variable of the dual is not zero, then the j-th variable of the primal is equal to zero. This necessary condition for optimality conveys
https://en.wikipedia.org/wiki/Linear_programming
. This necessary condition for optimality conveys a fairly simple economic principle. In standard form (when maximizing), if there is slack in a constrained primal resource (i.e., there are "leftovers"), then additional quantities of that resource must have no value. Likewise, if there is slack in the dual (shadow) price non-negativity constraint requirement, i.e., the price is not zero, then there must be scarce supplies (no "leftovers"). == Theory == === Existence of optimal solutions === Geometrically, the linear constraints define the feasible region, which is a convex polytope. A linear function is a convex function, which implies that every local minimum is a global minimum; similarly, a linear function is a concave function, which implies that every local maximum is a global maximum. An optimal solution need not exist, for two reasons. First, if the constraints are inconsistent, then no feasible solution exists: For instance, the constraints x ≥ 2 and x ≤ 1 cannot be satis
https://en.wikipedia.org/wiki/Linear_programming
e, the constraints x ≥ 2 and x ≤ 1 cannot be satisfied jointly; in this case, we say that the LP is infeasible. Second, when the polytope is unbounded in the direction of the gradient of the objective function (where the gradient of the objective function is the vector of the coefficients of the objective function), then no optimal value is attained because it is always possible to do better than any finite value of the objective function. === Optimal vertices (and rays) of polyhedra === Otherwise, if a feasible solution exists and if the constraint set is bounded, then the optimum value is always attained on the boundary of the constraint set, by the maximum principle for convex functions (alternatively, by the minimum principle for concave functions) since linear functions are both convex and concave. However, some problems have distinct optimal solutions; for example, the problem of finding a feasible solution to a system of linear inequalities is a linear programming problem in w
https://en.wikipedia.org/wiki/Linear_programming
inequalities is a linear programming problem in which the objective function is the zero function (i.e., the constant function taking the value zero everywhere). For this feasibility problem with the zero-function for its objective-function, if there are two distinct solutions, then every convex combination of the solutions is a solution. The vertices of the polytope are also called basic feasible solutions. The reason for this choice of name is as follows. Let d denote the number of variables. Then the fundamental theorem of linear inequalities implies (for feasible problems) that for every vertex x* of the LP feasible region, there exists a set of d (or fewer) inequality constraints from the LP such that, when we treat those d constraints as equalities, the unique solution is x*. Thereby we can study these vertices by means of looking at certain subsets of the set of all constraints (a discrete set), rather than the continuum of LP solutions. This principle underlies the simplex alg
https://en.wikipedia.org/wiki/Linear_programming
olutions. This principle underlies the simplex algorithm for solving linear programs. == Algorithms == === Basis exchange algorithms === ==== Simplex algorithm of Dantzig ==== The simplex algorithm, developed by George Dantzig in 1947, solves LP problems by constructing a feasible solution at a vertex of the polytope and then walking along a path on the edges of the polytope to vertices with non-decreasing values of the objective function until an optimum is reached for sure. In many practical problems, "stalling" occurs: many pivots are made with no increase in the objective function. In rare practical problems, the usual versions of the simplex algorithm may actually "cycle". To avoid cycles, researchers developed new pivoting rules. In practice, the simplex algorithm is quite efficient and can be guaranteed to find the global optimum if certain precautions against cycling are taken. The simplex algorithm has been proved to solve "random" problems efficiently, i.e. in a cubic n
https://en.wikipedia.org/wiki/Linear_programming
e "random" problems efficiently, i.e. in a cubic number of steps, which is similar to its behavior on practical problems. However, the simplex algorithm has poor worst-case behavior: Klee and Minty constructed a family of linear programming problems for which the simplex method takes a number of steps exponential in the problem size. In fact, for some time it was not known whether the linear programming problem was solvable in polynomial time, i.e. of complexity class P. ==== Criss-cross algorithm ==== Like the simplex algorithm of Dantzig, the criss-cross algorithm is a basis-exchange algorithm that pivots between bases. However, the criss-cross algorithm need not maintain feasibility, but can pivot rather from a feasible basis to an infeasible basis. The criss-cross algorithm does not have polynomial time-complexity for linear programming. Both algorithms visit all 2D corners of a (perturbed) cube in dimension D, the Klee–Minty cube, in the worst case. === Interior point === In c
https://en.wikipedia.org/wiki/Linear_programming
, in the worst case. === Interior point === In contrast to the simplex algorithm, which finds an optimal solution by traversing the edges between vertices on a polyhedral set, interior-point methods move through the interior of the feasible region. ==== Ellipsoid algorithm, following Khachiyan ==== This is the first worst-case polynomial-time algorithm ever found for linear programming. To solve a problem which has n variables and can be encoded in L input bits, this algorithm runs in O ( n 6 L ) {\displaystyle O(n^{6}L)} time. Leonid Khachiyan solved this long-standing complexity issue in 1979 with the introduction of the ellipsoid method. The convergence analysis has (real-number) predecessors, notably the iterative methods developed by Naum Z. Shor and the approximation algorithms by Arkadi Nemirovski and D. Yudin. ==== Projective algorithm of Karm
https://en.wikipedia.org/wiki/Linear_programming
and D. Yudin. ==== Projective algorithm of Karmarkar ==== Khachiyan's algorithm was of landmark importance for establishing the polynomial-time solvability of linear programs. The algorithm was not a computational break-through, as the simplex method is more efficient for all but specially constructed families of linear programs. However, Khachiyan's algorithm inspired new lines of research in linear programming. In 1984, N. Karmarkar proposed a projective method for linear programming. Karmarkar's algorithm improved on Khachiyan's worst-case polynomial bound (giving O ( n 3.5 L ) {\displaystyle O(n^{3.5}L)} ). Karmarkar claimed that his algorithm was much faster in practical LP than the simplex method, a claim that created great interest in interior-point methods. Since Karmarkar's discovery, many interior-point methods have been proposed and analyzed.
https://en.wikipedia.org/wiki/Linear_programming
ior-point methods have been proposed and analyzed. ==== Vaidya's 87 algorithm ==== In 1987, Vaidya proposed an algorithm that runs in O ( n 3 ) {\displaystyle O(n^{3})} time. ==== Vaidya's 89 algorithm ==== In 1989, Vaidya developed an algorithm that runs in O ( n 2.5 ) {\displaystyle O(n^{2.5})} time. Formally speaking, the algorithm takes O ( ( n + d ) 1.5 n L ) {\displaystyle O((n+d)^{1.5}nL)} arithmetic operations in the worst case, where d {\displaystyle d} is the number of constraints, n
https://en.wikipedia.org/wiki/Linear_programming
traints, n {\displaystyle n} is the number of variables, and L {\displaystyle L} is the number of bits. ==== Input sparsity time algorithms ==== In 2015, Lee and Sidford showed that linear programming can be solved in O ~ ( ( n n z ( A ) + d 2 ) d L ) {\displaystyle {\tilde {O}}((nnz(A)+d^{2}){\sqrt {d}}L)} time, where O ~ {\displaystyle {\tilde {O}}} denotes the soft O notation, and n n z
https://en.wikipedia.org/wiki/Linear_programming
n n z ( A ) {\displaystyle nnz(A)} represents the number of non-zero elements, and it remains taking O ( n 2.5 L ) {\displaystyle O(n^{2.5}L)} in the worst case. ==== Current matrix multiplication time algorithm ==== In 2019, Cohen, Lee and Song improved the running time to O ~ ( ( n ω + n 2.5 − α / 2 + n 2 + 1 / 6
https://en.wikipedia.org/wiki/Linear_programming
/ 6 ) L ) {\displaystyle {\tilde {O}}((n^{\omega }+n^{2.5-\alpha /2}+n^{2+1/6})L)} time, ω {\displaystyle \omega } is the exponent of matrix multiplication and α {\displaystyle \alpha } is the dual exponent of matrix multiplication. α {\displaystyle \alpha } is (roughly) defined to be the largest number such that one can multiply an n × n {\displaystyle n\times n} matrix by a n × n α {\displaystyle n\times n^{\alpha }} matrix in O ( n 2 ) {\displaystyle O(n^{2})} tim
https://en.wikipedia.org/wiki/Linear_programming
) {\displaystyle O(n^{2})} time. In a followup work by Lee, Song and Zhang, they reproduce the same result via a different method. These two algorithms remain O ~ ( n 2 + 1 / 6 L ) {\displaystyle {\tilde {O}}(n^{2+1/6}L)} when ω = 2 {\displaystyle \omega =2} and α = 1 {\displaystyle \alpha =1} . The result due to Jiang, Song, Weinstein and Zhang improved O ~ ( n 2 + 1
https://en.wikipedia.org/wiki/Linear_programming
2 + 1 / 6 L ) {\displaystyle {\tilde {O}}(n^{2+1/6}L)} to O ~ ( n 2 + 1 / 18 L ) {\displaystyle {\tilde {O}}(n^{2+1/18}L)} . === Comparison of interior-point methods and simplex algorithms === The current opinion is that the efficiencies of good implementations of simplex-based methods and interior point methods are similar for routine applications of linear programming. However, for specific types of LP problems, it may be that one type of solver is better than another (sometimes much better), and that the structure of the solutions generated by interior point m
https://en.wikipedia.org/wiki/Linear_programming
ure of the solutions generated by interior point methods versus simplex-based methods are significantly different with the support set of active variables being typically smaller for the latter one. == Open problems and recent work == There are several open problems in the theory of linear programming, the solution of which would represent fundamental breakthroughs in mathematics and potentially major advances in our ability to solve large-scale linear programs. Does LP admit a strongly polynomial-time algorithm? Does LP admit a strongly polynomial-time algorithm to find a strictly complementary solution? Does LP admit a polynomial-time algorithm in the real number (unit cost) model of computation? This closely related set of problems has been cited by Stephen Smale as among the 18 greatest unsolved problems of the 21st century. In Smale's words, the third version of the problem "is the main unsolved problem of linear programming theory." While algorithms exist to solve linear pr
https://en.wikipedia.org/wiki/Linear_programming
heory." While algorithms exist to solve linear programming in weakly polynomial time, such as the ellipsoid methods and interior-point techniques, no algorithms have yet been found that allow strongly polynomial-time performance in the number of constraints and the number of variables. The development of such algorithms would be of great theoretical interest, and perhaps allow practical gains in solving large LPs as well. Although the Hirsch conjecture was recently disproved for higher dimensions, it still leaves the following questions open. Are there pivot rules which lead to polynomial-time simplex variants? Do all polytopal graphs have polynomially bounded diameter? These questions relate to the performance analysis and development of simplex-like methods. The immense efficiency of the simplex algorithm in practice despite its exponential-time theoretical performance hints that there may be variations of simplex that run in polynomial or even strongly polynomial time. It would
https://en.wikipedia.org/wiki/Linear_programming
nomial or even strongly polynomial time. It would be of great practical and theoretical significance to know whether any such variants exist, particularly as an approach to deciding if LP can be solved in strongly polynomial time. The simplex algorithm and its variants fall in the family of edge-following algorithms, so named because they solve linear programming problems by moving from vertex to vertex along edges of a polytope. This means that their theoretical performance is limited by the maximum number of edges between any two vertices on the LP polytope. As a result, we are interested in knowing the maximum graph-theoretical diameter of polytopal graphs. It has been proved that all polytopes have subexponential diameter. The recent disproof of the Hirsch conjecture is the first step to prove whether any polytope has superpolynomial diameter. If any such polytopes exist, then no edge-following variant can run in polynomial time. Questions about polytope diameter are of indepen
https://en.wikipedia.org/wiki/Linear_programming
. Questions about polytope diameter are of independent mathematical interest. Simplex pivot methods preserve primal (or dual) feasibility. On the other hand, criss-cross pivot methods do not preserve (primal or dual) feasibility – they may visit primal feasible, dual feasible or primal-and-dual infeasible bases in any order. Pivot methods of this type have been studied since the 1970s. Essentially, these methods attempt to find the shortest pivot path on the arrangement polytope under the linear programming problem. In contrast to polytopal graphs, graphs of arrangement polytopes are known to have small diameter, allowing the possibility of strongly polynomial-time criss-cross pivot algorithm without resolving questions about the diameter of general polytopes. == Integer unknowns == If all of the unknown variables are required to be integers, then the problem is called an integer programming (IP) or integer linear programming (ILP) problem. In contrast to linear programming, whi
https://en.wikipedia.org/wiki/Linear_programming
) problem. In contrast to linear programming, which can be solved efficiently in the worst case, integer programming problems are in many practical situations (those with bounded variables) NP-hard. 0–1 integer programming or binary integer programming (BIP) is the special case of integer programming where variables are required to be 0 or 1 (rather than arbitrary integers). This problem is also classified as NP-hard, and in fact the decision version was one of Karp's 21 NP-complete problems. If only some of the unknown variables are required to be integers, then the problem is called a mixed integer (linear) programming (MIP or MILP) problem. These are generally also NP-hard because they are even more general than ILP programs. There are however some important subclasses of IP and MIP problems that are efficiently solvable, most notably problems where the constraint matrix is totally unimodular and the right-hand sides of the constraints are integers or – more general – where the sy
https://en.wikipedia.org/wiki/Linear_programming
ints are integers or – more general – where the system has the total dual integrality (TDI) property. Advanced algorithms for solving integer linear programs include: cutting-plane method Branch and bound Branch and cut Branch and price if the problem has some extra structure, it may be possible to apply delayed column generation. Such integer-programming algorithms are discussed by Padberg and in Beasley. == Integral linear programs == A linear program in real variables is said to be integral if it has at least one optimal solution which is integral, i.e., made of only integer values. Likewise, a polyhedron P = { x ∣ A x ≥ 0 } {\displaystyle P=\{x\mid Ax\geq 0\}} is said to be integral if for all bounded feasible objective functions c, the linear program { max c x ∣ x ∈ P }
https://en.wikipedia.org/wiki/Linear_programming
∣ x ∈ P } {\displaystyle \{\max cx\mid x\in P\}} has an optimum x ∗ {\displaystyle x^{*}} with integer coordinates. As observed by Edmonds and Giles in 1977, one can equivalently say that the polyhedron P {\displaystyle P} is integral if for every bounded feasible integral objective function c, the optimal value of the linear program { max c x ∣ x ∈ P } {\displaystyle \{\max cx\mid x\in P\}} is an integer. Integral linear programs are of central importance in the polyhedral aspect of combinatorial optimization since they provide an alternate characterization of a problem. Specifically, for any problem, the convex hull of the solutions is an integral polyhedron; if this polyhedron has a n
https://en.wikipedia.org/wiki/Linear_programming
an integral polyhedron; if this polyhedron has a nice/compact description, then we can efficiently find the optimal feasible solution under any linear objective. Conversely, if we can prove that a linear programming relaxation is integral, then it is the desired description of the convex hull of feasible (integral) solutions. Terminology is not consistent throughout the literature, so one should be careful to distinguish the following two concepts, in an integer linear program, described in the previous section, variables are forcibly constrained to be integers, and this problem is NP-hard in general, in an integral linear program, described in this section, variables are not constrained to be integers but rather one has proven somehow that the continuous problem always has an integral optimal value (assuming c is integral), and this optimal value may be found efficiently since all polynomial-size linear programs can be solved in polynomial time. One common way of proving that a polyh
https://en.wikipedia.org/wiki/Linear_programming
omial time. One common way of proving that a polyhedron is integral is to show that it is totally unimodular. There are other general methods including the integer decomposition property and total dual integrality. Other specific well-known integral LPs include the matching polytope, lattice polyhedra, submodular flow polyhedra, and the intersection of two generalized polymatroids/g-polymatroids – e.g. see Schrijver 2003. == Solvers and scripting (programming) languages == Permissive licenses: Copyleft (reciprocal) licenses: MINTO (Mixed Integer Optimizer, an integer programming solver which uses branch and bound algorithm) has publicly available source code but is not open source. Proprietary licenses: == See also == == Notes == == References == == Further reading == == External links == Guidance On Formulating LP Problems Mathematical Programming Glossary The Linear Programming FAQ Benchmarks For Optimisation Software
https://en.wikipedia.org/wiki/Linear_programming
Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect or "concern" of the desired functionality. A module interface expresses the elements that are provided and required by the module. The elements defined in the interface are detectable by other modules. The implementation contains the working code that corresponds to the elements declared in the interface. Modular programming is closely related to structured programming and object-oriented programming, all having the same goal of facilitating construction of large software programs and systems by decomposition into smaller pieces, and all originating around the 1960s. While the historical usage of these terms has been inconsistent, "modular programming" now refers to the high-level decomposition of the code of an entire program into pieces: structured programming to
https://en.wikipedia.org/wiki/Modular_programming
re program into pieces: structured programming to the low-level code use of structured control flow, and object-oriented programming to the data use of objects, a kind of data structure. In object-oriented programming, the use of interfaces as an architectural pattern to construct modules is known as interface-based programming. == History == Modular programming, in the form of subsystems (particularly for I/O) and software libraries, dates to early software systems, where it was used for code reuse. Modular programming per se, with a goal of modularity, developed in the late 1960s and 1970s, as a larger-scale analog of the concept of structured programming (1960s). The term "modular programming" dates at least to the National Symposium on Modular Programming, organized at the Information and Systems Institute in July 1968 by Larry Constantine; other key concepts were information hiding (1972) and separation of concerns (SoC, 1974). Modules were not included in the original specifica
https://en.wikipedia.org/wiki/Modular_programming
odules were not included in the original specification for ALGOL 68 (1968), but were included as extensions in early implementations, ALGOL 68-R (1970) and ALGOL 68C (1970), and later formalized. One of the first languages designed from the start for modular programming was the short-lived Modula (1975), by Niklaus Wirth. Another early modular language was Mesa (1970s), by Xerox PARC, and Wirth drew on Mesa as well as the original Modula in its successor, Modula-2 (1978), which influenced later languages, particularly through its successor, Modula-3 (1980s). Modula's use of dot-qualified names, like M.a to refer to object a from module M, coincides with notation to access a field of a record (and similarly for attributes or methods of objects), and is now widespread, seen in C++, C#, Dart, Go, Java, OCaml, and Python, among others. Modular programming became widespread from the 1980s: the original Pascal language (1970) did not include modules, but later versions, notably UCSD Pascal (
https://en.wikipedia.org/wiki/Modular_programming
modules, but later versions, notably UCSD Pascal (1978) and Turbo Pascal (1983) included them in the form of "units", as did the Pascal-influenced Ada (1980). The Extended Pascal ISO 10206:1990 standard kept closer to Modula2 in its modular support. Standard ML (1984) has one of the most complete module systems, including functors (parameterized modules) to map between modules. In the 1980s and 1990s, modular programming was overshadowed by and often conflated with object-oriented programming, particularly due to the popularity of C++ and Java. For example, the C family of languages had support for objects and classes in C++ (originally C with Classes, 1980) and Objective-C (1983), only supporting modules 30 years or more later. Java (1995) supports modules in the form of packages, though the primary unit of code organization is a class. However, Python (1991) prominently used both modules and objects from the start, using modules as the primary unit of code organization and "packages"
https://en.wikipedia.org/wiki/Modular_programming
e primary unit of code organization and "packages" as a larger-scale unit; and Perl 5 (1994) includes support for both modules and objects, with a vast array of modules being available from CPAN (1993). OCaml (1996) followed ML by supporting modules and functors. Modular programming is now widespread, and found in virtually all major languages developed since the 1990s. The relative importance of modules varies between languages, and in class-based object-oriented languages there is still overlap and confusion with classes as a unit of organization and encapsulation, but these are both well-established as distinct concepts. == Terminology == The term assembly (as in .NET languages like C#, F# or Visual Basic .NET) or package (as in Dart, Go or Java) is sometimes used instead of module. In other implementations, these are distinct concepts; in Python a package is a collection of modules, while in Java 9 the introduction of the new module concept (a collection of packages with enhanced
https://en.wikipedia.org/wiki/Modular_programming
le concept (a collection of packages with enhanced access control) was implemented. Furthermore, the term "package" has other uses in software (for example .NET NuGet packages). A component is a similar concept, but typically refers to a higher level; a component is a piece of a whole system, while a module is a piece of an individual program. The scale of the term "module" varies significantly between languages; in Python it is very small-scale and each file is a module, while in Java 9 it is planned to be large-scale, where a module is a collection of packages, which are in turn collections of files. Other terms for modules include unit, used in Pascal dialects. == Language support == Languages that formally support the module concept include Ada, ALGOL, BlitzMax, C++, C#, Clojure, COBOL, Common Lisp, D, Dart, eC, Erlang, Elixir, Elm, F, F#, Fortran, Go, Haskell, IBM/360 Assembler, Control Language (CL), IBM RPG, Java, Julia, MATLAB, ML, Modula, Modula-2, Modula-3, Morpho, NEWP, Ob
https://en.wikipedia.org/wiki/Modular_programming
, ML, Modula, Modula-2, Modula-3, Morpho, NEWP, Oberon, Oberon-2, Objective-C, OCaml, several Pascal derivatives (Component Pascal, Object Pascal, Turbo Pascal, UCSD Pascal), Perl, PHP, PL/I, PureBasic, Python, R, Ruby, Rust, JavaScript, Visual Basic (.NET) and WebDNA. In the Java programming language, the term "package" is used for the analog of modules in the JLS; — see Java package. "Modules", a kind of collection of packages, were introduced in Java 9 as part of Project Jigsaw; these were earlier called "superpackages" were planned for Java 7. Conspicuous examples of languages that lack support for modules are C and have been C++ and Pascal in their original form, C and C++ do, however, allow separate compilation and declarative interfaces to be specified using header files. Modules were added to Objective-C in iOS 7 (2013); to C++ with C++20, and Pascal was superseded by Modula and Oberon, which included modules from the start, and various derivatives that included modules. JavaSc
https://en.wikipedia.org/wiki/Modular_programming
various derivatives that included modules. JavaScript has had native modules since ECMAScript 2015. C++ modules have allowed backwards compatibility with headers (with "header units"). Dialects of C allow for modules, for example Clang supports modules for the C language, though the syntax and semantics of Clang C modules differ from C++ modules significantly. Modular programming can be performed even where the programming language lacks explicit syntactic features to support named modules, like, for example, in C. This is done by using existing language features, together with, for example, coding conventions, programming idioms and the physical code structure. IBM i also uses modules when programming in the Integrated Language Environment (ILE). == Key aspects == With modular programming, concerns are separated such that modules perform logically discrete functions, interacting through well-defined interfaces. Often modules form a directed acyclic graph (DAG); in this case a cycli
https://en.wikipedia.org/wiki/Modular_programming
directed acyclic graph (DAG); in this case a cyclic dependency between modules is seen as indicating that these should be a single module. In the case where modules do form a DAG they can be arranged as a hierarchy, where the lowest-level modules are independent, depending on no other modules, and higher-level modules depend on lower-level ones. A particular program or library is a top-level module of its own hierarchy, but can in turn be seen as a lower-level module of a higher-level program, library, or system. When creating a modular system, instead of creating a monolithic application (where the smallest component is the whole), several smaller modules are written separately so when they are composed together, they construct the executable application program. Typically, these are also compiled separately, via separate compilation, and then linked by a linker. A just-in-time compiler may perform some of this construction "on-the-fly" at run time. These independent functions are com
https://en.wikipedia.org/wiki/Modular_programming
" at run time. These independent functions are commonly classified as either program control functions or specific task functions. Program control functions are designed to work for one program. Specific task functions are closely prepared to be applicable for various programs. This makes modular designed systems, if built correctly, far more reusable than a traditional monolithic design, since all (or many) of these modules may then be reused (without change) in other projects. This also facilitates the "breaking down" of projects into several smaller projects. Theoretically, a modularized software project will be more easily assembled by large teams, since no team members are creating the whole system, or even need to know about the system as a whole. They can focus just on the assigned smaller task. == See also == Architecture description language – Standardized language on architecture description Cohesion (computer science) – Degree to which elements within a module belong toge
https://en.wikipedia.org/wiki/Modular_programming
gree to which elements within a module belong together Component-based software engineering – Engineering focused on building software from reusable components Conway's law – Adage linking organization and system structure Coupling (computer science) – Degree of interdependence between software modulesPages displaying short descriptions of redirect targets David Parnas – Canadian software engineer Information hiding – Principle of computer program design (encapsulation) Library (computing) – Collection of resources used to develop a computer program List of system quality attributes – Non-functional requirements for system evaluation Modular design – Design approach Plug-in (computing) – Software component that extends the functionality of existing software Snippet (programming) – Small region of re-usable source code, machine code, or text Structured Analysis – Software engineering methodPages displaying short descriptions of redirect targets Structured programming – Programming parad
https://en.wikipedia.org/wiki/Modular_programming
targets Structured programming – Programming paradigm based on control flow Cross-cutting concern – Concept in aspect-oriented software development == References == == External links == How To Decompose a System into Modules SMC Platform
https://en.wikipedia.org/wiki/Modular_programming
Pair programming is a software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer or navigator, reviews each line of code as it is typed in. The two programmers switch roles frequently. While reviewing, the observer also considers the "strategic" direction of the work, coming up with ideas for improvements and likely future problems to address. This is intended to free the driver to focus all of their attention on the "tactical" aspects of completing the current task, using the observer as a safety net and guide. == Economics == Pair programming increases the man-hours required to deliver code compared to programmers working individually. However, the resulting code has fewer defects. Along with code development time, other factors like field support costs and quality assurance also figure into the return on investment. Pair programming might theoretically offset these expenses by reducing defect
https://en.wikipedia.org/wiki/Pair_programming
retically offset these expenses by reducing defects in the programs. In addition to preventing mistakes as they are made, other intangible benefits may exist. For example, the courtesy of rejecting phone calls or other distractions while working together, taking fewer breaks at agreed-upon intervals or sharing breaks to return phone calls (but returning to work quickly since someone is waiting). One member of the team might have more focus and help drive or awaken the other if they lose focus, and that role might periodically change. One member might know about a topic or technique that the other does not, which might eliminate delays to finding or testing a solution, or allow for a better solution, thus effectively expanding the skill set, knowledge, and experience of a programmer as compared to working alone. Each of these intangible benefits, and many more, may be challenging to accurately measure but can contribute to more efficient working hours. == Design quality == A syste
https://en.wikipedia.org/wiki/Pair_programming
ient working hours. == Design quality == A system with two programmers possesses greater potential for the generation of more diverse solutions to problems for three reasons: the programmers bring different prior experiences to the task; they may assess information relevant to the task in different ways; they stand in different relationships to the problem by their functional roles. In an attempt to share goals and plans, the programmers must overtly negotiate a shared course of action when a conflict arises between them. In doing so, they consider a larger number of ways of solving the problem than a single programmer alone might do. This significantly improves the design quality of the program as it reduces the chances of selecting a poor method. == Satisfaction == In an online survey of pair programmers from 2000, 96% of programmers stated that they enjoyed working more while pair programming than programming alone. Furthermore, 95% said that they were more confident in their w
https://en.wikipedia.org/wiki/Pair_programming
95% said that they were more confident in their work when they pair programmed. However, as the survey was among self-selected pair programmers, it did not account for programmers who were forced to pair program. == Learning == Knowledge is constantly shared between pair programmers, whether in the industry or in a classroom. Many sources suggest that students show higher confidence when programming in pairs, and many learn whether it be from tips on programming language rules to overall design skills. In "promiscuous pairing", each programmer communicates and works with all the other programmers on the team rather than pairing only with one partner, which causes knowledge of the system to spread throughout the whole team. Pair programming allows programmers to examine their partner's code and provide feedback, which is necessary to increase their own ability to develop monitoring mechanisms for their own learning activities. == Team-building and communication == Pair programming
https://en.wikipedia.org/wiki/Pair_programming
am-building and communication == Pair programming allows team members to share quickly, making them less likely to have agendas hidden from each other. This helps pair programmers learn to communicate more easily. "This raises the communication bandwidth and frequency within the project, increasing overall information flow within the team." == Studies == There are both empirical studies and meta-analyses of pair programming. The empirical studies tend to examine the level of productivity and the quality of the code, while meta-analyses may focus on biases introduced by the process of testing and publishing. A meta-analysis found pairs typically consider more design alternatives than programmers working alone, arrive at simpler, more maintainable designs, and catch design defects earlier. However, it raised concerns that its findings may have been influenced by "signs of publication bias among published studies on pair programming." It concluded that "pair programming is not uniforml
https://en.wikipedia.org/wiki/Pair_programming
t concluded that "pair programming is not uniformly beneficial or effective." Although pair programmers may complete a task faster than a solo programmer, the total number of man-hours increases. A manager would have to balance faster completion of the work and reduced testing and debugging time against the higher cost of coding. The relative weight of these factors can vary by project and task. The benefit of pairing is greatest on tasks that the programmers do not fully understand before they begin: that is, challenging tasks that call for creativity and sophistication, and for novices as compared to experts. Pair programming could be helpful for attaining high quality and correctness on complex programming tasks, but it would also increase the development effort (cost) significantly. On simple tasks, which the pair already fully understands, pairing results in a net drop in productivity. It may reduce the code development time but also risks reducing the quality of the program. Prod
https://en.wikipedia.org/wiki/Pair_programming
so risks reducing the quality of the program. Productivity can also drop when novice–novice pairing is used without sufficient availability of a mentor to coach them. A study of programmers using AI assistance tools such as GitHub Copilot found that while some programmers conceived of AI assistance as similar to pair programming, in practice the use of such tools is very different in terms of the programmer experience, with the human programmer having to transition repeatedly between driver and navigator roles. == Indicators of non-performance == There are indicators that a pair is not performing well: Disengagement may present as one of the members physically withdraws away from the keyboard, accesses email, or even falls asleep. The "Watch the Master" phenomenon can arise if one member is more experienced than the other. In this situation, the junior member may take the observer role, deferring to the senior member of the pair for the majority of coding activity. This can easily l
https://en.wikipedia.org/wiki/Pair_programming
the majority of coding activity. This can easily lead to disengagement. == Pairing variations == Expert–expert Expert–expert pairing may seem to be the obvious choice for the highest productivity and can produce great results, but it often yields little insight into new ways to solve problems, as both parties are unlikely to question established practices. Expert–novice Expert–novice pairing creates many opportunities for the expert to mentor the novice. This pairing can also introduce new ideas, as the novice is more likely to question established practices. The expert, now required to explain established practices, is also more likely to question them. However, in this pairing, an intimidated novice may passively "watch the master" and hesitate to participate meaningfully. Also, some experts may not have the patience needed to allow constructive novice participation. Novice–novice Novice–novice pairing can produce results significantly better than two novices working independently,
https://en.wikipedia.org/wiki/Pair_programming
tly better than two novices working independently, although this practice is generally discouraged because it is harder for novices to develop good habits without a proper role model. == Remote pair programming == Remote pair programming, also known as virtual pair programming or distributed pair programming, is pair programming in which the two programmers are in different locations, working via a collaborative real-time editor, shared desktop, or a remote pair programming IDE plugin. Remote pairing introduces difficulties not present in face-to-face pairing, such as extra delays for coordination, depending more on "heavyweight" task-tracking tools instead of "lightweight" ones like index cards, and loss of verbal communication resulting in confusion and conflicts over such things as who "has the keyboard". Tool support could be provided by: Whole-screen sharing software Terminal multiplexers Specialized distributed editing tools Audio chat programs or VoIP software could be helpfu
https://en.wikipedia.org/wiki/Pair_programming
dio chat programs or VoIP software could be helpful when the screen sharing software does not provide two-way audio capability. Use of headsets keep the programmers' hands free Cloud development environments Collaborative pair programming services == See also == Extreme programming Joint attention Team programming (also known as mob programming) == References == == External links == wikiHow: How to Pair Program How-to guide; contains common wisdom on how to make pair programming work. Tuple:Pair Programming Guide Pair programming guide that covers paring styles, antipatterns, and more. Includes example paring videos. c2:PairProgramming c2:PairProgrammingPattern c2:PairRotationFrequency
https://en.wikipedia.org/wiki/Pair_programming
In computer science, declarative programming is a programming paradigm—a style of building the structure and elements of computer programs—that expresses the logic of a computation without describing its control flow. Many languages that apply this style attempt to minimize or eliminate side effects by describing what the program must accomplish in terms of the problem domain, rather than describing how to accomplish it as a sequence of the programming language primitives (the how being left up to the language's implementation). This is in contrast with imperative programming, which implements algorithms in explicit steps. Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming may greatly simplify writing parallel programs. Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming (e.g. Prolog, Datalog, answer set
https://en.wikipedia.org/wiki/Declarative_programming
ogic programming (e.g. Prolog, Datalog, answer set programming), functional programming, configuration management, and algebraic modeling systems. == Definition == Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions attempt to define it by simply contrasting it with imperative programming. For example: A high-level program that describes what a computation should perform. Any programming language that lacks side effects (or more specifically, is referentially transparent). A language with a clear correspondence to mathematical logic. These definitions overlap substantially. Declarative programming is a non-imperative style of programming in which programs describe their desired results without explicitly listing commands or steps that must be performed. Functional and logic programming languages are characterized by a declarative programming style. In logic programming, programs consist of sentences expres
https://en.wikipedia.org/wiki/Declarative_programming
programming, programs consist of sentences expressed in logical form, and computation uses those sentences to solve problems, which are also expressed in logical form. In a pure functional language, such as Haskell, all functions are without side effects, and state changes are only represented as functions that transform the state, which is explicitly represented as a first-class object in the program. Although pure functional languages are non-imperative, they often provide a facility for describing the effect of a function as a series of steps. Other functional languages, such as Lisp, OCaml and Erlang, support a mixture of procedural and functional programming. Some logic programming languages, such as Prolog, and database query languages, such as SQL, while declarative in principle, also support a procedural style of programming. == Subparadigms == Declarative programming is an umbrella term that includes a number of better-known programming paradigms. === Constraint programmi
https://en.wikipedia.org/wiki/Declarative_programming
programming paradigms. === Constraint programming === Constraint programming states relations between variables in the form of constraints that specify the properties of the target solution. The set of constraints is solved by giving a value to each variable so that the solution is consistent with the maximum number of constraints. Constraint programming often complements other paradigms: functional, logical, or even imperative programming. === Domain-specific languages === Well-known examples of declarative domain-specific languages (DSLs) include the yacc parser generator input language, QML, the Make build specification language, Puppet's configuration management language, regular expressions, Datalog, answer set programming and a subset of SQL (SELECT queries, for example). DSLs have the advantage of being useful while not necessarily needing to be Turing-complete, which makes it easier for a language to be purely declarative. Many markup languages such as HTML, MXML, XAML,
https://en.wikipedia.org/wiki/Declarative_programming
. Many markup languages such as HTML, MXML, XAML, XSLT or other user-interface markup languages are often declarative. HTML, for example, only describes what should appear on a webpage - it specifies neither control flow for rendering a page nor the page's possible interactions with a user. As of 2013, some software systems combine traditional user-interface markup languages (such as HTML) with declarative markup that defines what (but not how) the back-end server systems should do to support the declared interface. Such systems, typically using a domain-specific XML namespace, may include abstractions of SQL database syntax or parameterized calls to web services using representational state transfer (REST) and SOAP. === Functional programming === Functional programming languages such as Haskell, Scheme, and ML evaluate expressions via function application. Unlike the related but more imperative paradigm of procedural programming, functional programming places little emphasis on exp
https://en.wikipedia.org/wiki/Declarative_programming
nctional programming places little emphasis on explicit sequencing. Instead, computations are characterised by various kinds of recursive higher-order function application and composition, and as such can be regarded simply as a set of mappings between domains and codomains. Many functional languages, including most of those in the ML and Lisp families, are not purely functional, and thus allow the introduction of stateful effects in programs. === Hybrid languages === Makefiles, for example, specify dependencies in a declarative fashion, but include an imperative list of actions to take as well. Similarly, yacc specifies a context free grammar declaratively, but includes code snippets from a host language, which is usually imperative (such as C). === Logic programming === Logic programming languages, such as Prolog, Datalog and answer set programming, compute by proving that a goal is a logical consequence of the program, or by showing that the goal is true in a model defined by
https://en.wikipedia.org/wiki/Declarative_programming
owing that the goal is true in a model defined by the program. Prolog computes by reducing goals to subgoals, top-down using backward reasoning, whereas most Datalog systems compute bottom-up using forward reasoning. Answer set programs typically use SAT solvers to generate a model of the program. === Modeling === Models, or mathematical representations, of physical systems may be implemented in computer code that is declarative. The code contains a number of equations, not imperative assignments, that describe ("declare") the behavioral relationships. When a model is expressed in this formalism, a computer is able to perform algebraic manipulations to best formulate the solution algorithm. The mathematical causality is typically imposed at the boundaries of the physical system, while the behavioral description of the system itself is declarative or acausal. Declarative modeling languages and environments include Analytica, Modelica and Simile. == Examples == === Lisp === Lisp i
https://en.wikipedia.org/wiki/Declarative_programming
and Simile. == Examples == === Lisp === Lisp is a family of programming languages loosely inspired by mathematical notation and Alonzo Church's lambda calculus. Some dialects, such as Common Lisp, are primarily imperative but support functional programming. Others, such as Scheme, are designed for functional programming. In Scheme, the factorial function can be defined as follows: This defines the factorial function using its recursive definition. In contrast, it is more typical to define a procedure for an imperative language. In lisps and lambda calculus, functions are generally first-class citizens. Loosely, this means that functions can be inputs and outputs for other functions. This can simplify the definition of some functions. For example, writing a function to output the first n square numbers in Racket can be done accordingly: The map function accepts a function and a list; the output is a list of results of the input function on each element of the input list. === ML
https://en.wikipedia.org/wiki/Declarative_programming