Skip to content

Nonlinear Programming Model: Electric direct current model

Featured Replies

image.png

How to answer this question? What is the answers to a, b and c? Presently, I am working on this question.

Edited by Dhamnekar Win,odd
Spelling mistake corrected.

I suppose this can be cast as a linear programming model, though I am used to a more direct physical solution as the parallel operation of dissimilar power sources is an important real world situation

Is this homework/coursework ?

Assuming this is homework, a hint for (a)

Any linear programming problem requires the introduction of a constraint equation to bound the region where the constituent equations hold as there are not enough constituent equations by themselves (more unknowns than equations).

  • Author

Let's demystify the symbols first in the figure so that the rest of the math makes sense:

The straight lines are just wires. Think of them like pipes carrying water.

The squiggly lines are resistors. If wires are water pipes, resistors are narrow sections of the pipe that slow the water down. They are measured in "ohms."

The parallel lines with + and - signs are batteries (voltage sources). Think of these as the water pumps pushing the electricity through the pipes. They are measured in "volts." [math] I_1, I_2, I_3[/math] represent the current, which is the actual flow of electricity (like the water flowing through the pipes). The arrows show the direction the electricity is flowing.

Here is a plain-English breakdown of how to arrive at the answers for a, b, and c.

Part A: Explain the purpose of the constraint [math]I_1+I_2−I_3=0 [/math] In any model, a "constraint" is just a rule that reality forces us to follow.

Look at the top-middle intersection in the diagram, right above the middle resistor.

1)The current [math]I_1 [/math]is flowing into that intersection from the left side.

2)The current [math]I_2 [/math] is flowing into that intersection from the right side.

3)The current [math] I_3 [/math]is flowing downward, away from that intersection.

There is a fundamental rule in physics (called Kirchhoff's Current Law) that says electricity cannot just magically appear or disappear at an intersection. Whatever flows in must equal whatever flows out. So, if [math] I_1[/math] and [math]I_2 [/math] flow in, and [math]I_3 [/math] flows out, the equation is:

$$I_1+I_2=I_3$$

If you subtract [math] I_3 [/math] from both sides to get everything on one side of the equals sign, you get the constraint provided in the image:

$$I_1+I_2−I_3=0 $$

Purpose: This constraint ensures the math model obeys the physical law of conservation—it guarantees that no electrical current is mathematically "lost" or "created" at the junctions of the wires.

PART B:Write the nonlinear objective function

In mathematical programming, the "objective function" is the main formula you are trying to make as large as possible (maximize) or as small as possible (minimize).

Nature is lazy; electrical networks naturally distribute current in a way that minimizes the total energy "cost" or "effort" required to push that electricity through the resistors. In this specific mathematical framework, the function we want to minimize involves two parts:

1)The energy lost as heat in the resistors: The formula for this is [math]\displaystyle\frac{1}{2} \cdot Resistance \cdot Current. [/math]

2)The power supplied by the batteries: The formula for this is Voltage⋅Current.

We want to minimize the sum of the heat lost, minus the power supplied. Let's calculate the pieces:

Resistor 1 (10 ohms): [math]\displaystyle\frac12 \cdot 10⋅I^2_1=5\cdot I^2_1[/math]

Resistor 2 (20 ohms): [math]\displaystyle\frac12\cdot 20 \cdot I^2_2=10\cdot I^2_2[/math]

Resistor 3 (30 ohms): [math]\displaystyle\frac12\cdot 30\cdot I^2_3=15\cdot I^2_3[/math]

Battery 1 (10 volts): [math]10\cdot I_1[/math]

Battery 2 (5 volts): [math]5 \cdot I_2[/math]

If we add the resistor parts together and subtract the battery parts, we get our objective function (let's call it Z):

$$Z=5\cdot I^2_1+10\cdot I^2_2+15\cdot I^2_3−10\cdot I_1−5\cdot I_2$$

(This is considered "nonlinear" because the variables [math]I_1,I_2,I_3 [/math] are squared).

Part C: Is one assured of a global optimum?

Answer: Yes, you are absolutely assured of a global optimum

Here is how to justify that based on parts a and b:

A "global optimum" means the solver finds the absolute best possible answer, rather than getting stuck on a "pretty good but not the best" answer (a local optimum).

To guarantee a global optimum when minimizing a function, two things must be true:

1)The constraint must be "linear" (forming a flat, simple shape). Our constraint from part A [math] (I_1+I_2−I_3 = 0)[/math] has no squared variables. It is purely linear.

2)The objective function must be "convex" (shaped like a bowl). Look at the squared terms in our objective function from part B [math] (5I^2_1, 10I^2_2, 15I^2_3) [/math] Because all of those coefficients (5, 10, 15) are positive numbers, mathematically, the shape of the function is a perfectly smooth, upward-facing bowl.

A bowl only has exactly one bottom point. Because we are minimizing a bowl-shaped (convex) function on a flat (linear) constraint, there is only one lowest point in the entire model. Therefore, a tool like Excel Solver will flawlessly find the absolute global optimum every time.

I obtained the following values using Excel Solver

$$I_1\approx 0.318182, I_2\approx −0.09091, I_3 \approx 0.227273$$

The fact that I used the QPCONVEX (Quadratic Programming Convex) model is perfect; it recognizes that my objective function is a "bowl-shaped" quadratic, which is why it was able to find the global optimum so efficiently.

Verification of the Results

To verify that the answer is correct, we can check it against our two "rules" from earlier:

1)The Constraint Check [math](I_1+I_2−I_3=0): [/math] * If you add 0.318182 (Input) and −0.09091 (Input), you get 0.227272.

Since [math]I_3[/math]is 0.227273 (Output), the balance is zero (allowing for tiny rounding differences). This proves my model followed the law of conservation of current.

2)The Objective Value (Z=−1.36364):

This represents the absolute minimum energy state of the system. In any other combination of currents that satisfy the constraint, this number would be higher (less optimal).

Edited by Dhamnekar Win,odd

18 hours ago, Dhamnekar Win,odd said:

PART B:Write the nonlinear objective function

In mathematical programming, the "objective function" is the main formula you are trying to make as large as possible (maximize) or as small as possible (minimize).

Nature is lazy; electrical networks naturally distribute current in a way that minimizes the total energy "cost" or "effort" required to push that electricity through the resistors. In this specific mathematical framework, the function we want to minimize involves two parts:

1)The energy lost as heat in the resistors: The formula for this is 12⋅ResistanceCurrent.

Whilst I agree that energy considerations will produce solvable solutions via the shakedown theorem, I don't agree with your energy loss formula.

Energy is not 1/2 resistance times current squared.

Power is resistance times current squared , not one half of that,

Energy is power times time.

Edited by studiot

  • Author

You are absolutely right about the standard physics definitions, and your skepticism shows you have a solid grasp of the fundamentals! Let’s clear up why there is a discrepancy between the physics of energy and the mathematical optimization model used here.

1. Physics vs. Optimization (The "1/2" Mystery)

In physics, you are 100% correct:

  • Power ([math]P[/math]): [math]P = R \cdot I^2[/math](This is Joule's Law).

  • Energy ([math]E[/math]): [math]E = P \cdot t = R \cdot I^2 \cdot t[/math].

However, in Mathematical Programming (Optimization), we often use a modified version of these formulas to simplify the calculus. When a solver like the one we used (QPCONVEX) looks for a minimum, it calculates the derivative (the rate of change) of the function.

In calculus, the derivative of [math]I^2[/math]is 2I. By putting a [math]1/2[/math]in front of the [math]R \cdot I^2[/math] term in the objective function, the [math]1/2[/math] and the [math]2[/math] cancel out perfectly during the math operations:

$$\frac{d}{dI} \left( \frac{1}{2} R \cdot I^2 \right) = R \cdot I$$

This makes the resulting equations much "cleaner" to solve because [math]R \cdot I[/math] is simply the Voltage Drop across the resistor (V = IR).

2. The Objective Function is a "Proxy"

The objective function Z in your model isn't actually measuring "Total Joules of Energy" in the literal sense. Instead, it is a mathematical proxy called the Content of the circuit.

  • In optimization theory for networks, we minimize the "Content" to find the steady state.

  • The "Content" of a resistor is defined as [math]\int_0^I V(i) di[/math].

  • Since V = Ri, the integral [math]\int_0^I (Ri) di[/math] results in [math]\frac{1}{2}RI^2[/math].

3. Summary of Definitions

To answer your question directly:

  • Is [math]P = RI^2[/math]correct? Yes, for physical power loss.

  • Is Energy [math]P \cdot t[/math] correct? Yes, for physical energy consumed over time.

  • Is the model's formula wrong? Physically, yes; Mathematically, no. The 1/2 is a standard convention in quadratic programming to ensure that the "answer" (the currents) aligns with Kirchhoff’s Voltage Law (V = IR) without extra coefficients hanging around.

In standard physics:

$$P = R \cdot I^2$$

In the optimization model (Minimizing Content):

$$f(I) = \frac{1}{2} R \cdot I^2 - V \cdot I$$

The derivative yields the steady-state voltage balance:

$$\frac{df}{dI} = R \cdot I - V = 0 \implies V = IR$$

Edited by Dhamnekar Win,odd

This kind of problem I can be solved making simultaneous equations using Kirchoff's voltage and current laws.

If you search " solving problems using kirchhoff's voltage and current equations" you should find the information you need "

An alternative method applicable to this type of problem is known as the superposition theorem.

Edited by OldTony

I1≈0.318182,I2≈−0.09091,I3≈0.227273

I agree with those currents, but here's the thing. The lead to a voltage at the junction of the 3 resistors of just over 6.8 volts.

I am not sure if you are studying maths or electrical engineering ?

But why would anyone connect up two batteries as your 'model' has shown ?

What do you know about your model ?

I am not at all convinced that your 'lazy' objective function correctly identifes the minimum heat dissipation in the three resistors.

The actual values of the three currents varies with the voltage at the triple junction.

I have prepared an Excel spreadsheet of the currents for each of the possible voltages 1 through 9 and plotted the result to find a minimum total power at just over 8 volts (not 6,8 as you have).

These were calculated using the correct power formulae without fiddle factors.

dissipatedpower.jpg

  • 2 weeks later...
  • Author

This is a fantastic technical critique. You have touched on the exact point where "textbook physics" meets "optimization theory," and your skepticism is well-founded.

The discrepancy between your 8V result and the model's 6.8V result isn't a "fiddle factor" error; it is a fundamental difference between two different principles of circuit analysis.

1. The Conflict: Power vs. Content

You are looking for the Minimum Power Dissipation ([math]P = RI^2[/math]). This is a very logical physical goal, but surprisingly, Nature does not actually minimize total power in a DC circuit.

Instead, circuits reach equilibrium by minimizing a mathematical quantity called Content ([math]G = \frac{1}{2}RI^2[/math]). This is known as Maxwell's Principle of Minimum Heat (or the Principle of Stationary Content).

  • Your Model (Minimizing Power): By minimizing [math]\sum RI^2[/math], you are finding the state where the circuit is "most efficient" as a heater.

  • The Physics Model (Minimizing Content): By minimizing [math]\sum \frac{1}{2}RI^2 - \sum VI[/math], the solver is finding the state that satisfies Kirchhoff's Voltage Law (KVL).

If you minimize pure power ([math]RI^2[/math]), you will get an answer, but that answer will violate Kirchhoff's Laws. If you built this circuit on a breadboard and measured it with a multimeter, the junction voltage would indeed be 6.81V, matching the "1/2" model, not the 8V result.

2. Why use the "1/2" anyway?

In optimization, the "1/2" is used so that when you take the derivative (to find the minimum), the 2 from the exponent cancels out:

$$\frac{d}{dI} \left( \frac{1}{2} RI^2 \right) = RI$$

This RI is the Voltage Drop. The solver is essentially looking for the point where the sum of these drops equals the battery voltage. Without that 1/2, the solver would be looking for the point where 2RI = V, which would effectively double all your resistances!

3. "Why would anyone connect batteries like this?"

You are absolutely right—in a real-world product, this is a bad design. Connecting a 10V battery and a 5V battery in parallel like this results in:

  • Back-charging: The 10V battery is forcing current into the 5V battery.

  • Waste: Significant energy is lost as heat ([math]I^2R[/math]) just fighting between the two sources.

This model is typically used in Electrical Engineering 101 or Math Modeling courses precisely because it is "messy." It forces students to deal with negative currents and proves that Kirchhoff's Laws work even in poorly designed or "fighting" systems.

4. Comparison of Results

Feature

Your Excel Result

The Solver/Physics Result

Junction Voltage

~8.0 V

6.81 V

Satisfies KVL?

No

Yes

Satisfies KCL?

Likely Yes

Yes

Principle Used

Min. Total Power

Min. Content (Maxwell)

The Verdict: Your Excel plot is a perfect mathematical exercise in minimizing a function ([math]RI^2[/math]), but that function doesn't describe how electrons actually behave. The "fiddle factor" version is actually the one that correctly predicts the physical reality of the circuit.

Edited by Dhamnekar Win,odd

8 hours ago, Dhamnekar Win,odd said:

This is a fantastic technical critique. You have touched on the exact point where "textbook physics" meets "optimization theory," and your skepticism is well-founded.

The discrepancy between your 8V result and the model's 6.8V result isn't a "fiddle factor" error; it is a fundamental difference between two different principles of circuit analysis.

1. The Conflict: Power vs. Content

You are looking for the Minimum Power Dissipation (P=RI2). This is a very logical physical goal, but surprisingly, Nature does not actually minimize total power in a DC circuit.

Instead, circuits reach equilibrium by minimizing a mathematical quantity called Content (G=12RI2). This is known as Maxwell's Principle of Minimum Heat (or the Principle of Stationary Content).

  • Your Model (Minimizing Power): By minimizing ∑RI2, you are finding the state where the circuit is "most efficient" as a heater.

  • The Physics Model (Minimizing Content): By minimizing ∑12RI2−∑VI, the solver is finding the state that satisfies Kirchhoff's Voltage Law (KVL).

If you minimize pure power (RI2), you will get an answer, but that answer will violate Kirchhoff's Laws. If you built this circuit on a breadboard and measured it with a multimeter, the junction voltage would indeed be 6.81V, matching the "1/2" model, not the 8V result.

2. Why use the "1/2" anyway?

In optimization, the "1/2" is used so that when you take the derivative (to find the minimum), the 2 from the exponent cancels out:

ddI(12RI2)=RI

This RI is the Voltage Drop. The solver is essentially looking for the point where the sum of these drops equals the battery voltage. Without that 1/2, the solver would be looking for the point where 2RI = V, which would effectively double all your resistances!

3. "Why would anyone connect batteries like this?"

You are absolutely right—in a real-world product, this is a bad design. Connecting a 10V battery and a 5V battery in parallel like this results in:

  • Back-charging: The 10V battery is forcing current into the 5V battery.

  • Waste: Significant energy is lost as heat (I2R) just fighting between the two sources.

This model is typically used in Electrical Engineering 101 or Math Modeling courses precisely because it is "messy." It forces students to deal with negative currents and proves that Kirchhoff's Laws work even in poorly designed or "fighting" systems.

4. Comparison of Results

Feature

Your Excel Result

The Solver/Physics Result

Junction Voltage

~8.0 V

6.81 V

Satisfies KVL?

No

Yes

Satisfies KCL?

Likely Yes

Yes

Principle Used

Min. Total Power

Min. Content (Maxwell)

The Verdict: Your Excel plot is a perfect mathematical exercise in minimizing a function (RI2), but that function doesn't describe how electrons actually behave. The "fiddle factor" version is actually the one that correctly predicts the physical reality of the circuit.

I asked you three questions but you only answered one of them.

I asked all three for good reasons, because it is no use being clever with maths if you are either using the wrong model or do not properly understand the 'correct' model.

That is why I asked if this is electrical engineering or mathematical modelling.

It should be remembered that the electrical symbols you have employed refer to perfect or ideal components.

So both voltage sources are ideal.

Do you understand the significance of that ?

Equally all three resistors are ideal.

But what do you imagine R1 (10 ohms) , and R2 (20ohms) actually are ?

An electrical engineer would immediately say they are the internal series resistances of real world sources.

This makes a difference to how the circuit and the model operate.

I also asked why would anyone connect two batteries like this.

Well they wouldn't because neither 5 volt nor 10 volt batteries actually exist.

But here is a real world electrical engineering situation where one might.

We have a nominal 1.5 volt battery that is somewhat discharged to 1.4 volts and we wish to boost its performance by adding in parallel a smaller but fresh 1.5 cell we have in the cupboard.

The resultant voltage will never reach 1.5 volts but will be greater than 1.4 volts, which may be sufficient for our purposes.

For calculation purposes assume the larger, but discharged battery has an internal resistance of 0.1 ohms and the smaller fresh battery has an internal resistance of 0.2 ohms.

Such a parallel combination of batteries would then be used to supply a load RL which would be R3 (30 ohms) in your model circuit.

At this point I owe you an apology since I misread you initial post that sought a nonlinear programming approach and thought you meant a linear programming solution.

In point of fact an electrical engineer could perform a linear programming exercise on my battery problem, based on load lines which in this case are indeed straight lines.

By drawing or calculating a load line for each battery, a load line for the parallel combination can be deduced to find the terminal voltage and thus the currents flowing in the loops.

It is necessary to understand the action of an ideal voltage source and the concept of its terminal voltage.

Addendum

You should be very wary of Kirchoff's Laws are they are actually a rather convenient fiction.

This was known as the famous crisis in the history of electromagnetic theory and was resolved in Maxwell in the 1860s.

Consider a single wire that is not connected in one end and explain why Kirchoff predicts that zero current can flow into and out of this wire.

For without such current radio transmission would simply not work.

7 hours ago, studiot said:

Addendum

You should be very wary of Kirchoff's Laws are they are actually a rather convenient fiction.

hold good?This was known as the famous crisis in the history of electromagnetic theory and was resolved in Maxwell in the 1860s.

Consider a single wire that is not connected in one end and explain why Kirchoff predicts that zero current can flow into and out of this wire.

For without such current radio transmission would simply not work.

The circuit given is a dc circuit and a radio aerial only transmits when given an ac signal to create a magnetic field. Surely in a dc circuit Kirchoff's equations hold good ?

3 hours ago, OldTony said:

The circuit given is a dc circuit and a radio aerial only transmits when given an ac signal to create a magnetic field. Surely in a dc circuit Kirchoff's equations hold good ?

Just to add. My understanding is that Kirchoff's laws and equations apply to ac circuits if you add " at any given instant of time".

Kirchoff's laws are a very convenient fiction in a similar way to centrifugal force and other imaginary forces such as such as virtual work.

They work in the right circumstances, in that they produce the same answer as calculations with models more aligned to physical reality.

Here is a short extract from the late Professor Shercliff's excellent book 'Vector Fields' - Cambridge University Press.

J A Shercliff was Dean of Engineering and Applied Maths at Warwick, after leafing a distinguished early career in Magento Hydro Dynamics at Cambridge, Oxford and the UKEA

Sorry for the integrals, j is current and q is charge.

shercliff1.jpg

4 hours ago, studiot said:

Kirchoff's laws are a very convenient fiction in a similar way to centrifugal force and other imaginary forces such as such as virtual work.

They work in the right circumstances, in that they produce the same answer as calculations with models more aligned to physical reality.

Here is a short extract from the late Professor Shercliff's excellent book 'Vector Fields' - Cambridge University Press.

J A Shercliff was Dean of Engineering and Applied Maths at Warwick, after leafing a distinguished early career in Magento Hydro Dynamics at Cambridge, Oxford and the UKEA

Sorry for the integrals, j is current and q is charge.

shercliff1.jpg

It seems to me that Professor Shercliff is really focussing on transient conditions on switching on or off dc circuits and the operation of ac circuits. I notice the diagram does not include one or more switches therefore I would assume steady state conditions would be the purpose of the question. In any case even during the transient period, as I understand it, Kirchoff's laws apply at any specific point at any specific instant of time. Whether wanted or not every circuit has some inductance and some capacitance which have their effect during the transient period of microseconds or nanoseconds, but once the transient period is over neither has an effect in the steady state.

Screenshot 2026-03-21 at 18.03.16.png

28 minutes ago, OldTony said:

It seems to me that Professor Shercliff is really focussing on transient conditions on switching on or off dc circuits and the operation of ac circuits. I notice the diagram does not include one or more switches therefore I would assume steady state conditions would be the purpose of the question. In any case even during the transient period, as I understand it, Kirchoff's laws apply at any specific point at any specific instant of time. Whether wanted or not every circuit has some inductance and some capacitance which have their effect during the transient period of microseconds or nanoseconds, but once the transient period is over neither has an effect in the steady state.

There's nothing transient about a whip antenna transmitting or receiving CW.

I think you have misunderstood my intentions anyway.

The OP has admitted that the circuit as show serves no useful purpose, and it is also unclear whether the resistors R1 and R2 are the battery internal series resistors or not.

Either way the three resistors are the only way power can be dissipated by this circuit, ideal voltage sources dissipate zero power.

Therefore the input power must equal the resistive dissipation in the three resistors and his defining equation is a figment.

I have tried to widen the discussion to something that comes a little closer to the real world, by discussing load lines.

The configuration is actually very important in the electrical power industry where it appears as the parallel connection of generators.

When the sources are alternating there are phase and other changes to consider.

Further Sherwood's description of the circuit he shows specifically states that Kirchoff is not obeyed at switchon, and explains why.

Equally you say that Kirchoff's laws are obeyed at every point. A small issue here as one is a loop law, not a point law,

Create an account or sign in to comment

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.