Integer Linear Programming
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A Integer Linear Programming Integer linear programming (ILP) is a mathematical optimization technique applica- ble to a large number of optimization problems. ILP models provide a general approach for modeling optimization problems. ILP models consist of two parts: a cost function and a set of constraints. Both parts involve references to a set X ={xi } of integer-valued variables. Cost functions must be linear functions of those variables. So, they must be of the general form C = ai xi , with ai ∈ R, xi ∈ N0 (A.1) i The set J of constraints must also consist of linear functions of integer-valued vari- ables. They must be of the form ∀ j ∈ J : bi, j xi ≥ c j with bi, j , c j ∈ R (A.2) i Definition A.1: The integer linear programming (ILP-) problem is the problem of minimizing the cost function of equation (A.1) subjects to the constraints given in Eq. (A.2). If all variables are constrained to being either 0 or 1, the corresponding model is called a 0/1-integer linear programming model. In this case, variables are also denoted as (binary) decision variables. Note that ≥ can be replaced by ≤ in Eq. (A.2) if constants bi, j are modified accord- ingly. Also, the case of negative variables xi (i.e., allowing xi to have any integer value) can be transformed into the case of nonnegative variables shown above by multiplying constants by –1. Applications requiring maximizing some gain func- tion C can be changed into the above form by setting C =−C. Equations may be represented by pairs of constraints, but they are typically used to eliminate some variables. © Springer International Publishing AG 2018 379 P. Marwedel, Embedded System Design, Embedded Systems, DOI 10.1007/978-3-319-56045-8 380 Appendix A: Integer Linear Programming For example, assuming that x1, x2, and x3 must be integers, the following set of equations represent a 0/1-IP model: C = 5x1 + 6x2 + 4x3 (A.3) x1 + x2 + x3 ≥ 2(A.4) x1 ≤ 1(A.5) x2 ≤ 1(A.6) x3 ≤ 1(A.7) Due to the constraints, all variables are either 0 or 1. There are four possible solutions. These are listed in TableA.1. The solution with a cost of 9 is optimal. Table A.1 Possible solutions x1 x2 x3 C of the presented ILP problem 0 1 1 10 1 0 1 9 1 1 0 11 1 1 1 15 ILP is a variant of linear programming (LP). For linear programming, variables can take any real values. ILP and LP models can be solved optimally using mathematical programming techniques. Unfortunately, ILP is NP-complete (but LP is not) and ILP execution times may become very large. Nevertheless, ILP models are useful for modeling optimization problems as long as the model sizes are not extremely large. Modeling optimization problems as integer linear programming problems make sense despite the complexity of the problem: Many problems can be solved in acceptable execution times and if they cannot, ILP models provide a good starting point for heuristics. Execution times depend on the number of variables and on the number and structure of the constraints. Good ILP solvers (like lp_solve [15]orCPLEX) can solve well-structured problems containing a few thousand variables in acceptable computation times (e.g., minutes). For more information on ILP and LP, refer to books on the topic (e.g., to Wolsey [566]). Appendix B Kirchhoff’s Laws and Operational Amplifiers Our presentation of D/A converters on page 188 assumes some basic knowledge about operational amplifiers. This knowledge is frequently lacking among computer science students, and therefore, the necessary fundamentals are presented in this Appendix. These fundamentals require an understanding of Kirchhoff’s laws, of which students will also be reminded in this Appendix. Kirchhoff’s Laws Kirchhoff’s laws provide a means for analyzing electrical circuits. The first rule is Kirchhoff’s Current Law, also called Kirchhoff’s Junction Rule, or Kirchhoff’s First Law. The rule applies to junctions such as the one shown in Fig.B.1. Fig. B.1 Junction in an i electrical circuit 1 i i2 R’ 4 R i 3 Theorem B.1 (Kirchhoff’s Current Law): At any point in an electrical circuit, the sum of currents flowing toward that point is equal to the sum of currents flowing away from that point [261]. Formally, for any node in a circuit we have: ik = 0(B.1) k If Kirchhoff’s law is used in the form of equation (B.1), currents denoted by arrows pointing away from the node must be counted as negative, and this counting is independent of the direction into which electrons are actually flowing. © Springer International Publishing AG 2018 381 P. Marwedel, Embedded System Design, Embedded Systems, DOI 10.1007/978-3-319-56045-8 382 Appendix B: Kirchhoff’s Laws and Operational Amplifiers Example B.1: For the currents of Fig. B.1,wehave i1 + i2 − i3 + i4 = 0(B.2) i1 + i2 + i4 = i3 (B.3) This invariance exists due to the conservation of electrical charge. Without this rule, the total electrical charge would not remain constant, and the voltage would increase. Kirchhoff’s second rule applies to loops in a circuit. It is known as Kirchhoff’s Voltage Law, Kirchhoff’s Loop Rule, or Kirchhoff’s Second Law. FigureB.2 shows an example. Fig. B.2 Loop in an electrical circuit 3 I 3 R 3 R 244 1 Theorem B.2 (Kirchhoff’s Voltage Law): The sum of the potential differences (voltages) across all elements around any closed circuit must be zero [261]. Formally, for any loop in a circuit we have: Vk = 0(B.4) k If we traverse voltages against the arrow direction, we have to count them as negative. Example B.2: For the schematic of Fig. B.2,wehave V1 − V2 − V3 + V4 = 0(B.5) The underlying reason for this invariance is the conservation of energy. Without this rule, we could accelerate charge in the loop and the charge would accumulate energy without any energy consumption elsewhere. In general, it is not relevant into which direction electrons are actually flowing and which of two terminals are actually positive with respect to some other terminal. Arrows can be selected in an arbitrary way. We just have to make sure that we respect the direction of the arrows when we apply Kirchhoff’s laws. If arrows for voltages and currents across components are pointing in opposite directions, the equation for that component has to take that into account. Appendix B: Kirchhoff’s Laws and Operational Amplifiers 383 Example B.3: Ohm’s law for resistor R3 in Fig. B.2 reads as follows, due to the opposite directions of voltage and current arrows: V3 I3 =− (B.6) R3 Of course, we will typically try to define the direction of voltages and currents such that we avoid having too many minus signs. Operational Amplifiers In electronics, there is frequently the need to amplify some signal x(t) in order to obtain some amplified signal y(t) = a · x(t), with a > 1. a is called the gain. Designing different circuits for each and every gain would be a laborious task. Therefore, designers are frequently using a general amplifier which can be easily configured to have the required gain. Such a general amplifier is called operational amplifier, or op-amp for short. Op-amps are designed for a very large maximum gain. The required actual gain can be adjusted with a proper selection of a few hardware components in the circuit surrounding the op-amp. More precisely, an operational amplifier is a component having two signal inputs and one signal output. In addition, there are at least two power supply inputs (see Fig. B.3). Fig. B.3 Operational supply voltage amplifier − op−amp + ground Op-amps amplify the difference between the voltages at the two signal inputs with respect to ground by a gain g: Vout = g ∗ (V+ − V−) (B.7) g is called the open loop gain and is typically very large (104 < g < 106). For an ideal op-amp, g would approach infinity. Furthermore, op-amps usually come with a very high input impedance (> 1M). Hence, we can frequently ignore signal input currents. For an ideal op-amp, the input impedance would be infinity and input currents would be zero. 384 Appendix B: Kirchhoff’s Laws and Operational Amplifiers Op-amps have been commercially available for decades, both as separate inte- grated circuits and within other circuits. They differ by their speed, their voltage ranges, their current drive capability, and other characteristics. The actual gain of the circuit is selected with external resistors. Figure B.4 shows how this can be done. Fig. B.4 Op-amp with I R 1 feedback R − op−amp + 1 Any small voltage between the two signal inputs is amplified by a large factor. Via resistor R1, the resulting output voltage is fed back. feedback is to the inverting input and therefore, any positive voltage V− results in a negative voltage Vout and vice versa. This means that the feedback will work against the input voltage, and it does so very strongly, due to the large amplification. Therefore, the feedback will reduce the voltage at the input pin. The question is: By how much? We can use Kirchhoff’s rules to find the resulting voltage V− (see Fig. B.5). Fig. B.5 Op-amp with R I 1 feedback (loop highlighted) R loop − op−amp + 1 ground Due to the characteristics of op-amps, we have Vout =−g ∗ V− (B.8) Due to Kirchhoff’s law for the loop shown by a dashed line in Fig.