11
votes
Accepted
Markov (Chain) image generators?
I've implemented this recently, basically it counts how many times each specific colour borders another colour to make up a frequency table. To generate an image, a random colour and position are ...
5
votes
Constrained simulated annealing
Simulated annealing comes from computations in statistical mechanics. When I think of simulated annealing, I very much think in terms of physics: I want to minimize some potential energy function that ...
5
votes
Accepted
Solving constrained odes's using inbuilt solvers in Matlab/Octave
Yes you can. If the term that multiplies $N$ is never zero, then $N$ is an algebraic variable of index 1. Its combination with the ODEs on $x$ yields a system of differentiel-algebraic equations (DAEs)...
5
votes
Accepted
sum of absolute difference constraint in optimization problem
The way to deal with this kind of constraint is to add "slack variables" to your system. In your case, let us say that you want to solve the problem
$$
\min_a c^T a \\
\text{subject to}\; \sum_{i=...
4
votes
Accepted
Constraints 'exactly/at most one non-zero element' without binary variables
No, this is not possible. There is a standard way of showing this:
The feasible region of your constraints is not convex. For example, $x_{1,1}=1$, $x_{1,2}=0$ is feasible, $x_{1,1}=0$, $x_{1,2}=1$ ...
3
votes
Accepted
Solving linear system of equations with constraints on unknowns
I will use the notation $U_k$ and $U_{k,i}$ for rows and elements of matrix $U$, rather than small letter $u$, to avoid possible confusion with the $u_k$ notation in $y_k=au_k+bu_{k-1}+cu_{k−2}+pa^2u^...
3
votes
Accepted
Setting up optimization problem in GEKKO
A good first step with any parameter estimation problem is to solve it in simulation to verify that you can get a good solution and that the parameters have an effect on the objective. You can first ...
3
votes
Accepted
What are the various methods in adding an additional constraint to the quadratic spline interpolation problem
End slope for quadratic splines is a generalization of the natural quadratic spline condition: $p'_0(x_0) = v_0$. Alternatively, you could specify instead $p'_n(x_{n+1}) = v_{n+1}$. Since $\mathcal{C}...
3
votes
How to get all intersections between two simple polygons in O(n+k)
In the general case, this cannot be done in $O(n+k)$ time, as there can be as many as $4\lfloor\frac{n}{2}\rfloor\lfloor\frac{k}{2}\rfloor$, i.e., Θ(nk) intersection points.
If the two polygons are ...
2
votes
Simple methods for solving 2D steady incompressible flow?
I cannot comment, so as an answer may I recommend looking at something like:
http://lorenabarba.com/blog/cfd-python-12-steps-to-navier-stokes/
form start to finish?
This takes the reader from basic ...
2
votes
Trajectory optimization for smoothness
You will have to transcribe the control problem in some manner so that you can feed it to a non-linear programming solver. You may want to look at Matthew Kelly's paper for a good introduction to ...
2
votes
Making difference of log constraints convex
Let $z_i = \log p_i$ (i.e. $p_i = e^{z_i}$) and everything changes to linear constraints except the constraint $\sum e^{z_i} = 1$ which you can relax to $\sum e^{z_i} \leq 1$ since it will be tight at ...
2
votes
Making difference of log constraints convex
The constraints are not convex. Consider the example below in which x1 and x2 are each vectors of 3 elements which satisfy the inequality in question, as shown. 0.5(x1 + x2) does not satisfy the ...
2
votes
Linear constraints for L-BFGS-B
One approach to this problem is to reparameterize your problem in terms of
$x_{1}$
and
$z_{i}=x_{i}-x_{i-1}$, $i=2, \ldots, n-1$.
You can then rewrite your objective function in terms of the the ...
2
votes
Solve integral equation for unknown constant
Like what @Kirill says, write a script that defines $f(u)$ to be a function that approximates the integral. Thus all that you need to is solve $f(u)=0$ which can use standard root finding tools like ...
2
votes
How to add damped constraint force to constrained dynamics simulation?
It seems there is no easy answer to your question, and I think what you are trying to do is not possible unless you restrict somehow the set of constraints that you want to consider.
As a simple ...
2
votes
Accepted
How to best code a problem with scipy, cvxpy or Convex.jl with given generated data
With your constraints of $a = 1$ and $c = -\frac{b}{d} - 1$, your $f$ looks like this:
$$\hat{\mathbf{y}} = f(\mathbf{x},b,d) = \frac{bd}{d\exp{(\mathbf{x})}-b - d} + d$$
You're trying to solve a ...
2
votes
Accepted
Is there a way to bound the values of a variable when using scipy.integrate.solve_ivp in python?
If the exact solution indeed stays within [0,1], the solver may still resolve too coarsely the dynamics and "jump" over the physical bounds. One way to solve this is to use lower absolute ...
2
votes
Accepted
Constraint programming problem with conditional constraints and some unknown indicator variables
You should have a look at Satisfiability Modulo Theories or SMT for short.
A huge number of problems can be thought of as instances of SMT for a particular theory.
For example, correctly designing ...
1
vote
1
vote
Markov (Chain) image generators?
Blog post on an experimentation using Markov to recreate art:
https://magenta.as/using-machine-learning-to-make-art-84df7d3bb911
Code is on github made by @william-index:
https://github.com/william-...
1
vote
Newton's method with box-constraints
You should put "mirrors" to bracket your domain.
For example, in a one-dimensional case:
If I know that my unknown $x$ is bounded between $0$ and $a$. At each iteration of my method, i will check if ...
1
vote
Accepted
Eigenvalue problem constrained with a penalty method
I found the error, I just need to constrain the implied identity matrix on the right-hand-side too:
...
1
vote
Simple methods for solving 2D steady incompressible flow?
Ironically, there is an iterative method called "SIMPLE" (semi-implicit method for pressure-linked equations) designed to resolve the steady state navier-stokes equations based on a predictor-...
1
vote
Simple methods for solving 2D steady incompressible flow?
With the continuity eqn only, you are missing all the mechanical balance: viscous and/or inertial effects will decide of the streamlines of such a flow.
If your major aim is to keep it as simple as ...
1
vote
How to handle the quadratic constraint $x y \leq z$?
To me it looks you are dealing with a standard Geometric Program (GP) which can be handled easily by commercial solvers (see e.g. https://www.cvxpy.org/tutorial/dgp/index.html)
1
vote
How to handle the quadratic constraint $x y \leq z$?
If this is the only relevant part of your problem, you can write this as a semidefinite program. Since $x_1, x_2$ do not appear individually you can treat it as a square of a positive number then your ...
1
vote
Nonlinear least squares with box constraints
The R minpack.lm CRAN package provides a Levenberg-Marquardt implementation with box constraints.
In general, Levenberg-Marquardt is much better suited than L-BFGS-B for least-squares problems. It ...
1
vote
Nonlinear least squares with box constraints
(Years later) two solvers that handle box constraints:
Scipy least_squares
has 3 methods, with extensive doc:
'trf’: Trust Region Reflective
'dogbox'
'lm': a legacy wrapper for MINPACK, without box ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
constraints × 55constrained-optimization × 17
optimization × 13
finite-element × 8
convex-optimization × 8
ode × 4
numerics × 3
computational-physics × 3
computational-geometry × 3
linear-algebra × 2
matlab × 2
python × 2
finite-difference × 2
boundary-conditions × 2
nonlinear-equations × 2
iterative-method × 2
simulation × 2
scipy × 2
runge-kutta × 2
nonlinear-programming × 2
newton-method × 2
least-squares × 2
linear-system × 2
combinatorics × 2
lagrange-multiplier × 2