Re: A priority of constrains for scipy.optimize.minimize
Change your loss function to a penalized form.
Instead of minimizing L(x)
f_1(x) (necessary constraint)
f_2(x) (nice but not necessary constraint)
Do this instead:
Minimize L(x) + \lambda * f_2(x)
where \lambda can be a hyper parameter you can tune to trade off how important constraint f_2 is relative to loss function quality.
Alternatively: if you are doing minimization on a probability simplex, you can probably re-parametrize your problem so the only viable solution automatically satisfies those probabilities. The most common way is to run your output through a softmax (https://en.wikipedia.org/wiki/Softmax_function)
Date: Tue, 5 Feb 2019 02:07:35 +0100
From: Jan Hendrik Berlin <[hidden email]>
To: SciPy-User <[hidden email]>
Subject: [SciPy-User] A priority of constrains for
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8; format=flowed
I am solving a problem with some constrains. At first there is a
constraint, that the sum of the percentages must be 1. The single
percentage could be in the range from 0,0 to 1. And this is the main
constraint. On the other side there are some constrains belonging to
stuff of the calculation. It is possible, that this constrains are to
strong and the solver can't get a solution. In this Case I want to have
an option to get a solution respecting the first constraint.
Has anybody an idea of a solution? I think there is no option for a
priority of the constrains.