# Constraint problem

**URL:** <https://discourse.julialang.org/t/constraint-problem/12261>\
**Category:** New to Julia\
**Created:** [July 8, 2018, 11:09pm UTC](https://discourse.julialang.org/t/constraint-problem/12261 "2018-07-08T23:09:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [July 8, 2018, 11:09pm UTC](https://discourse.julialang.org/t/constraint-problem/12261/1 "2018-07-08T23:09:22Z")

</div>

I want to solve a constraint problem.

(I have no experience with solvers or optimization and not sure of terminology, I think it’s mixed-integer, non-linear or black box constraint feasibility problem?)

Here’s what I want to do:

```julia
Input Variables:
w::Vector{Int}
w is integer vector of length ~20

Mappings:
y = f(w), where f(w::Vector{Int}) -> y::Vector{Float64}
f is somewhat complicated, definitely non-linear
y is same length as w

Constraints:
f(w)[19] == c1
f(w)[20] == c2
dot(f(w), v) == c3, where v is a constant Vector{Int}
These constraints may be satisfied within a certain tolerance

```

Note this could be simplified by separating into 2 independent problems and making vector `v` variable:

```julia
    1. find w, subject to f(w)[19], f(w)[20] constraints
    2. find v, subject to dot(f(w), v) constraint

```

Note also that I already have a solution `v1`, `w1`, but now want to find `v2`, `w2` subject to:

```julia
f(w2)[19] == f(w1)[19]
f(w2)[20] == f(w1)[20] * 2
dot(f(w2), v2) == dot(f(w1), v1)

```

I think this means I have good initial values for the problem?

I’d appreciate any advice on how I could tackle this?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [July 9, 2018, 2:18am UTC](https://discourse.julialang.org/t/constraint-problem/12261/2 "2018-07-09T02:18:19Z")

</div>

Check out [JuMP](http://www.juliaopt.org/JuMP.jl/0.18/).

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [July 9, 2018, 7:18am UTC](https://discourse.julialang.org/t/constraint-problem/12261/3 "2018-07-09T07:18:41Z")

</div>

> [@greg\_plowman](#):
>
> I think it’s mixed-integer, non-linear or black box constraint feasibility problem?

Yeah, looks like a mixed-integer nonlinear program (MINLP). It might be small enough that you can try to solve it to guaranteed global optimality using a dedicated MINLP solver. For example, you could try JuMP with [Couenne](https://projects.coin-or.org/Couenne) as the solver. Couenne has Julia bindings: [GitHub - rdeits/CouenneNL.jl](https://github.com/rdeits/CouenneNL.jl). Couenne is definitely not the fastest MINLP solver, but it is free.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 9, 2018, 3:07pm UTC](https://discourse.julialang.org/t/constraint-problem/12261/4 "2018-07-09T15:07:48Z")

</div>

There is also [POD.jl](https://github.com/lanl-ansi/POD.jl).

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [July 9, 2018, 3:10pm UTC](https://discourse.julialang.org/t/constraint-problem/12261/5 "2018-07-09T15:10:04Z")

</div>

I haven’t tried POD yet. How is it? Faster than Couenne?

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [July 9, 2018, 3:10pm UTC](https://discourse.julialang.org/t/constraint-problem/12261/6 "2018-07-09T15:10:59Z")

</div>

Didn’t try it either. There is also [Juniper.jl](https://github.com/lanl-ansi/Juniper.jl). More and more Julia solvers are showing up, this is great!
