∇ProvenDecisions
Ctrl K

Water-filling power allocation: a convex optimization example, solved and checked

The water-filling power allocation is a classic convex optimization problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.

Answer. You asked for: the power allocated to each channel (p1, p2, p3, p4). The largest objective value is 1.97755, at p1 = 0.649973, p2 = 0.350027, p3 = 5.77313e-08, p4 = 3.28869e-09. All 5 constraints are satisfied exactly. Optimal, numerically checked.

Solve your own version free, no account needed

The problem

Split 1 watt of transmit power over four channels with noise levels of 0.2, 0.5, 0.9 and 1.5 watts to maximize the total capacity, the sum of log(1 + power_i / noise_i), with each power in watts. How much power goes to each channel?

How the model was built

The objective as written from the problem, before the numbers are multiplied out:

The model

Each line has a plain-language note on the right.

make as large as possible: total capacity, sum of log(1 + power_i / noise_i) (nats)
limit 1: left side cannot exceed 1
power allocated to channel 1 with noise 0.2 (watts) cannot be negative
power allocated to channel 2 with noise 0.5 (watts) cannot be negative
power allocated to channel 3 with noise 0.9 (watts) cannot be negative
power allocated to channel 4 with noise 1.5 (watts) cannot be negative

What is being decided

There are 4 decision variables.

VariableTypeMeaning
p1real numberpower allocated to channel 1 with noise 0.2 (watts)
p2real numberpower allocated to channel 2 with noise 0.5 (watts)
p3real numberpower allocated to channel 3 with noise 0.9 (watts)
p4real numberpower allocated to channel 4 with noise 1.5 (watts)

Goal and limits

Maximize total capacity, sum of log(1 + power_i / noise_i) (nats) subject to 5 constraints, of which 4 are simple bounds on a single variable.

Problem type

Conic (convex), complexity level 4: convex nonlinear functions such as log, exp, square roots or powers. Solved with CLARABEL at the Medium solver tier.

The answer at a glance

The optimal value of each decision, as the solver returned it.

p10.649973p20.350027p35.77313e-08p43.28869e-09

Which constraints hold the answer in place

Binding (no slack left): (1) p1 + p2 + p3 + p4 <= 1; (4) p3 >= 0; (5) p4 >= 0. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
1p1 + p2 + p3 + p4 <= 1112.52302e-09yes
2p1 >= 00.64997300.649973
3p2 >= 00.35002700.350027
4p3 >= 05.77313e-0805.77313e-08yes
5p4 >= 03.28869e-0903.28869e-09yes

Algebraic model (low level)

Decision variables, objective and every constraint written out; this is exactly what the solver receives.

Model code (cvxpy)

The same model in cvxpy, ready to run.

import cvxpy as cp

p1 = cp.Variable(name='p1')  # power allocated to channel 1 with noise 0.2 (watts)
p2 = cp.Variable(name='p2')  # power allocated to channel 2 with noise 0.5 (watts)
p3 = cp.Variable(name='p3')  # power allocated to channel 3 with noise 0.9 (watts)
p4 = cp.Variable(name='p4')  # power allocated to channel 4 with noise 1.5 (watts)

objective = cp.Maximize(cp.log(5.0*p1 + 1) + cp.log(2.0*p2 + 1) + cp.log(1.11111111111111*p3 + 1) + cp.log(0.666666666666667*p4 + 1))
constraints = [
    p1 + p2 + p3 + p4 <= 1,
    p1 >= 0,
    p2 >= 0,
    p3 >= 0,
    p4 >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('p1 =', p1.value)
print('p2 =', p2.value)
print('p3 =', p3.value)
print('p4 =', p4.value)

Solve your own

This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).

maximize log(1 + p1/0.2) + log(1 + p2/0.5) + log(1 + p3/0.9) + log(1 + p4/1.5)
subject to
p1 + p2 + p3 + p4 <= 1
p1, p2, p3, p4 >= 0
# p1 = power allocated to channel 1 with noise 0.2 (watts)
# p2 = power allocated to channel 2 with noise 0.5 (watts)
# p3 = power allocated to channel 3 with noise 0.9 (watts)
# p4 = power allocated to channel 4 with noise 1.5 (watts)
# objective = total capacity, sum of log(1 + power_i / noise_i) (nats)
# asked: the power allocated to each channel (p1, p2, p3, p4)

Change the numbers and solve it

Checked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, SCS) agree on. Built 2026-11-10.

Related examples

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: