# Minimize function of matrix subject to matrix equality

**URL:** https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701
**Category:** Optimization (Mathematical)
**Created:** [May 3, 2020, 8:46pm UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701 "2020-05-03T20:46:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![uncertainly](https://avatars.discourse-cdn.com/v4/letter/u/aeb1de/32.png) [@uncertainly](https://discourse.julialang.org/u/uncertainly)
#### Post date: [May 3, 2020, 8:46pm UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/1 "2020-05-03T20:46:49Z")

</div>

newbie here, both to julia, JuMP, only intermediate at optimization.

I would like to solve a problem

```julia
   min(A) subject to C = B*A

```

where `A,B,C` are all matrices.

Is it possible to express this in JuMP? Any hints please?

---

<div class="post-metadata">

### Author: ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)
#### Post date: [May 3, 2020, 9:13pm UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/2 "2020-05-03T21:13:50Z")

</div>

What do you mean by minimizing a Matrix?

JuMP works very well for minimizing scalars. You can find many examples in [JuMPTutorials.jl](https://github.com/JuliaOpt/JuMPTutorials.jl)

You could use that to minimize some norm of the matrix.

There is experimental work on multi-objetive ([Multiobjective support in JuMP · Issue #2099 · jump-dev/JuMP.jl · GitHub](https://github.com/JuliaOpt/JuMP.jl/issues/2099)).

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 4, 2020, 11:40am UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/3 "2020-05-04T11:40:42Z")

</div>

I think you mean `min f(A)` for some function `f(A)`?

If the matrix `B` is small enough to solve explicitly for its null space `N = nullspace(B)`, then you can completely eliminate this constraint. If `X = B \ C` is a particular solution, then write `A = X + N*Z` where `Z` is an unknown matrix. You then have an _unconstrained_ minimization problem: minimize `f(X + N*Z)` over `Z`.

---

<div class="post-metadata">

### Author: ![uncertainly](https://avatars.discourse-cdn.com/v4/letter/u/aeb1de/32.png) [@uncertainly](https://discourse.julialang.org/u/uncertainly)
#### Post date: [May 5, 2020, 2:40am UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/4 "2020-05-05T02:40:42Z")

</div>

err, that was a typo! First post and I was paying more attention to how to post than to what I wrote.

yes I meant

```julia
    min f(A) subject to C = B*A

```

where f() returns a scalar

---

<div class="post-metadata">

### Author: ![uncertainly](https://avatars.discourse-cdn.com/v4/letter/u/aeb1de/32.png) [@uncertainly](https://discourse.julialang.org/u/uncertainly)
#### Post date: [May 5, 2020, 2:41am UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/5 "2020-05-05T02:41:38Z")

</div>

Is it possible to solve the proposed constrained problem?  
Any hints on what the syntax would be?

The problem is that I think the particular f() no longer makes sense if applied to the sum X+N\*Z, it has specific meaning for the matrix A.

---

<div class="post-metadata">

### Author: ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)
#### Post date: [May 5, 2020, 3:06am UTC](https://discourse.julialang.org/t/minimize-function-of-matrix-subject-to-matrix-equality/38701/6 "2020-05-05T03:06:02Z")

</div>

note that `X+N*Z` is a matrix with the same dimensions of `A` so there should be no problem computing `f` of that.

can you say something else about `f`?  
you only have equalities and no inequalities?
