Skip to main content

Questions tagged [constraints]

For questions about computationally solving a problem subject to some constraints on the solution. For optimizations, apply the more specific [constrained-optimization] tag instead.

Filter by
Sorted by
Tagged with
10 votes
4 answers
4k views

Nonlinear least squares with box constraints

What are recommended ways of doing nonlinear least squares, min $\sum err_i(p)^2$, with box constraints $lo_j <= p_j <= hi_j$ ? It seems to me (fools rush in) that one could make the box ...
denis's user avatar
  • 932
9 votes
2 answers
4k views

Markov (Chain) image generators?

Markov Chains can be used to generate, or auto-complete, text. https://en.wikipedia.org/wiki/Markov_chain#Markov_text_generators Training text is read, and some information about the text is ...
alan2here's user avatar
  • 193
8 votes
2 answers
5k views

How to get all intersections between two simple polygons in O(n+k)

Basically the formulation of the problem I'd like to solve is very simple. Given 2 simple polygons (without self-intersections) report all intersecting edge pairs in O(n+k) time, where n - is a total ...
Sergei Ivanov's user avatar
7 votes
1 answer
2k views

Constrained simulated annealing

Simulated annealing is a useful technique for finding near-optimal solutions to combinatorial problems. I have found a lot of tutorials on implementing the basic algorithm, but miss a general guide as ...
user3124074's user avatar
6 votes
1 answer
2k views

Newton's method with box-constraints

I have to use an iterative method (Newton-Raphson, modified Newton and Broyden) to solve a system of nonlinear equations $f(x)=0$. Every unknown $x_i$ is bounded between $l_i$ and $u_i$, i.e., $l_i<...
Manu's user avatar
  • 459
5 votes
2 answers
505 views

Linear regression with quadratic constraints

What methods are suggested to solve problems of the form $\min || {A} x - y ||_k$, subject to $x^T P x \leq c$, and/or $x^T Q x = d$?
Emre's user avatar
  • 348
5 votes
2 answers
493 views

Prescribe solution of a PDE at specific points

I am using MATLAB's PDE toolbox to solve the differential equation $-\nabla\cdot\left(c(x)\nabla u(x)\right) + a(x)u(x) = f(x)$ The particular problem in question is an electrostatic problem, but ...
Stuart Barth's user avatar
5 votes
1 answer
121 views

Projection on Stiefel manifold after integration step

A few days ago, I asked how constraints like $A^T A = I$ can be implemented if one wishes to integrate differential equations of the form $\dot{A}=f(A,t)$. Kirill was so kind to point out that a ...
Merlin1896's user avatar
5 votes
1 answer
161 views

What are the various methods in adding an additional constraint to the quadratic spline interpolation problem

I am taking a class on numerical analysis. While the professor was deriving the theory behind quadratic splines, the professor mentioned that a quadratic spline function has the form: $$ p_{i}(x)=a_{i}...
User19212341's user avatar
5 votes
2 answers
572 views

What does symmetrize mean? (imposing multifreedom constraints to stiffness matrix)

I have a small FEM implementation program. And I want to add imposing multifreedom constraints (MFC) feature to it. The theory of master-slave method is given here (page 10 for general case). ...
danny_23's user avatar
  • 501
4 votes
1 answer
1k views

solving a linearly-constrained sparse linear least-squares problem

[ question reposted from https://math.stackexchange.com/questions/786612/solving-a-linearly-constrained-sparse-linear-least-squares-problem ] Given the system of equations $Ax=b$, subject to $Cx\le ...
strangelyput's user avatar
4 votes
1 answer
572 views

What is the probabilistic model behind sudoku grids?

I'm talking about the vanilla sudoku game, with 9x9 grids equally split into 9 regions. I've tried a few approaches to estimate the probability that a specific number is in a specific location, but I ...
user avatar
4 votes
1 answer
508 views

Transform from constrained to unconstrained optimization

In a constrained optimization problem, I found in a paper a way to define new variables such that the constraints disappear. They only give the new variable definitions, and I would like to understand ...
J-D's user avatar
  • 41
3 votes
1 answer
751 views

BFGS methods for constrained elasticity problems

My dear community, I am wondering why BFGS methods are not so widely used for simulating mechanical problems which heavily still relies on inverting the hessian matrix. I am essentially interested ...
tom's user avatar
  • 41
3 votes
1 answer
226 views

Integration of differential equation with orthogonality constraint

Lets say I have a system of differential equations which has the form $$\dot{C}_{\alpha,\beta,m} = f_{\alpha,\beta,m}(C_{\alpha,\beta,1},\ldots,C_{\alpha,\beta,N};t).$$ The $f$s are some functions of ...
Merlin1896's user avatar
3 votes
1 answer
1k views

Setting up optimization problem in GEKKO

I have the following dynamical system, $\frac{d \phi}{dt} = -M^TDM\phi \tag{1}\label{1}$ $\frac{d \hat\phi}{dt} = -M^T\tilde{D}M\hat \phi \tag{2} \label{2}$ $\eqref{1}$ represents the exact ...
Natasha's user avatar
  • 433
3 votes
1 answer
144 views

What's the best way to handle a quadratic constraint

What is the best way to handle a constraint of the type $ax_1^2+x_2^2+...+x_n^2=c$ in a gradient descent algorithm? I would like to solve an optimization problem of the type: $$ \min J(x_1,..,x_n)$$ ...
Beni Bogosel's user avatar
  • 1,077
3 votes
1 answer
1k views

Linear constraints for L-BFGS-B

I know L-BFGS-B only supports simple box constrains of the form: $l_i \leq x_i \leq u_i$, where $l_i$ and $u_i$ are constants. For my specific optimization problem, I need to specify some simple ...
Costis's user avatar
  • 1,330
3 votes
2 answers
141 views

How does constraint resolution affect the stability/accuracy of numerical integration?

I understand some basic analysis techniques (local truncation error, global error, zero-stable, absolute stable, etc.) of numerical integration. But I find it hard to apply these techniques in ...
TheBusyTypist's user avatar
3 votes
0 answers
261 views

Hanging nodes in deal.ii tutorials: how is the continuity constraint imposed?

While looking at step6 of deal.ii tutorials, I decided to try to understand how the constraints coming from hanging nodes are imposed. So I started by watching video lecture 16 by prof. Bangerth As ...
FEGirl's user avatar
  • 435
3 votes
0 answers
404 views

How much better a bounded BFGS is compared to augmented Lagrangian method with BFGS?

I mean, in handling boxed constraints? In terms of stability, and more importantly, the numerical performance? I have already written some well-optimized and well-tested C/CUDA/C++ codes for ...
user0002128's user avatar
2 votes
2 answers
212 views

How to impose a constant constraint PDE

What is the best way to impose a "constant constraint" for a PDE? Specifically, I want to solve an eigenvalue problem $Au=\lambda u$ on the rectangle $(0,2\pi)\times(-\pi/2,\pi/2)$ with periodicity ...
Beni Bogosel's user avatar
  • 1,077
2 votes
1 answer
76 views

Solving constrained odes's using inbuilt solvers in Matlab/Octave

I would like to solve a set of coupled second order differential equations using inbuilt Matlab/Octave subroutines. These equations arise when trying to model sliding of mass ($m_2$) over a wedge of ...
Salil S. Kulkarni's user avatar
2 votes
1 answer
237 views

Constraints 'exactly/at most one non-zero element' without binary variables

In a much larger MINLP problem, I have set of variables $\{a_{ij}\}_{m,n}$, such that $0 \leq a_{ij} \leq 1 $ for all $i$, $j$, which I could think of as a matrix, for which I have two requirements: ...
user1372338's user avatar
2 votes
4 answers
1k views

Simple methods for solving 2D steady incompressible flow?

I'm trying to make a CFD model where I can place a source and a sink anywhere in a grid and get the fluid flow rate across each cell boundary between those locations. I'm starting simple with a 3x3 ...
Calvin's user avatar
  • 21
2 votes
2 answers
1k views

Quadratic program With Linear Constraint vs. Eigen Decomposition Time Complexity-Comparison. Which is faster?

Say I had the choice of choosing one out of the following two optimization problems which I could use to solve my problem. Which choice is the fastest? How much of a trade-off would it be-as in - Is ...
hearse's user avatar
  • 259
2 votes
1 answer
163 views

How to add damped constraint force to constrained dynamics simulation?

I have implemented a constraint dynamics physics simulation as proposed by Andrew Witkin et al 1990, but I cannot get the initial constraint "snapping" correctly. I implemented $$ JWJ^{T} \...
EmmanuelMess's user avatar
2 votes
1 answer
2k views

Is there a way to bound the values of a variable when using scipy.integrate.solve_ivp in python?

I want to solve an IVP in python with two variables, x and u, but I need the values of u to be between 0 and 1. Right now it is giving me a solution with negative values for u. Here is the code I have....
user606273's user avatar
2 votes
3 answers
649 views

How to handle the quadratic constraint $x y \leq z$?

I have a quadratic constraint of the form $$ x_1 x_2 \leq x_3 $$ where $x_1, x_2, x_3 \geq 0$. The objective is linear, and all other constraints are linear, too. I know that I can transform the ...
DDCh's user avatar
  • 41
2 votes
0 answers
92 views

How "kinematic" rigid bodies are implemented in physics engines

In most physics engines there's this concept of "static" bodies, which act as rigid bodies with infinite mass. Then there are "kinematic" bodies that act as static bodies, but ...
Lenny White's user avatar
2 votes
0 answers
37 views

Differences in using Clausius-Duhem inequality vs Principle of Virtual Work/Power in derriving constitutive equations?

I am a novice getting my toes wet in continuum mechanics and nonlinear elasticity. I have seen papers that use both approaches in developing constitutive connections to compliment balance equations of ...
TheCodeNovice's user avatar
2 votes
0 answers
723 views

What is the mathematical and physical principle behind of RBE2 element?

I am writing a 3d linear finite element code to solve the standard linear elasticity equation on a tetrahedron mesh of a gearbox. Notice that, the two rectangular plates above the gearbox are fixed, ...
Huayi Wei's user avatar
  • 143
2 votes
0 answers
36 views

Domain for convex perspective function

The perspective of a function $f : \mathbb{R}^n \to \mathbb{R}$ is the function $g: \mathbb{R}^n \times \mathbb{R} \to \mathbb{R}$ where $g$ is defined as $$g(x,t) = tf(x/t)$$ with $$\mathbf{\text{dom}...
jjjjjj's user avatar
  • 325
2 votes
0 answers
85 views

About Convex Geometry

A consistency notion in constraint programming: Let $P = (X, D, C)$ be a CSP. Given a set of variables $Y \subseteq X$ with $|Y| = k -1$, a locally consistent instantiation $I$ on $Y$ is $k$-...
Limeme90's user avatar
1 vote
4 answers
169 views

Solve Large Scale Underdetermined Linear Equation with per Element Equality Constraint

I have the following system on $\boldsymbol{x}$: $$ \boldsymbol{A} \boldsymbol{x} = \boldsymbol{0}, \quad \text{subject to} \; {x}_{i} = {v}_{i} \; \forall i \in \mathcal{V} $$ Where $\boldsymbol{A} \...
Royi's user avatar
  • 573
1 vote
1 answer
1k views

sum of absolute difference constraint in optimization problem

I am writing a model for an optimization problem. I need to write the following constraint: $$\sum^{N - 1}_i \lvert (a_i - a_{i+1}) \rvert \leq 2\, .$$ How to write this constraint (or linearize)? ...
os12's user avatar
  • 13
1 vote
2 answers
160 views

Making difference of log constraints convex

I have the discrete likelihood estimation problem $\max \sum m_i\log p_i $ where $m$ is a given vector of length $n$. The constraints are $0 \preceq p \preceq 1$, $\sum_{i=1}^n p_i = 1, $ and one ...
quiet's user avatar
  • 111
1 vote
1 answer
498 views

Minimization constraints without using Lagrange Multiplier

Currently, I am working on an unconstrained energy minimization function, but I need to add some constraints. My system is a 2D lattice with a force applied to it, and I want the sides to be able to ...
alpha-helix1123's user avatar
1 vote
1 answer
207 views

Solving linear system of equations with constraints on unknowns

I would like to solve a system of linear equations $y=Uh$ for an unknown vector $h$, where I have a few constraints on some of the elements of $h$. The matrix $U$ is composed of a vector $u$ (length $...
Neuling's user avatar
  • 35
1 vote
1 answer
1k views

Convex Polygon Intersection

Determining the intersection of two convex polygons is one of the fundamental problems in computational geometry . I'm asking for an algorithm having: INPUT: Given two convex polygons P and Q in 2D (...
Limeme90's user avatar
1 vote
1 answer
563 views

How to best code a problem with scipy, cvxpy or Convex.jl with given generated data

I have a curve fitting problem of the form: $$ \textbf{y} = f(\textbf{x}, a,b,c,d) + \varepsilon $$ $$ f(x, a,b,c,d) = \frac{b}{e^{x\cdot a}+c}+d $$ with the constraint \begin{equation} \begin{aligned}...
ecjb's user avatar
  • 141
1 vote
1 answer
86 views

Constraint programming problem with conditional constraints and some unknown indicator variables

I have an interesting little problem that I believe can be formulated in terms of optimization or constraint programming. I have a few dozen variables $a$, $b$, $c$ ... and a set of constraints that ...
Evan Honnold's user avatar
1 vote
1 answer
860 views

Trajectory optimization for smoothness

I want to achieve the following in 2D (and without obstacles): Given start position A and end position B, generate the path between the two points that optimizes a cost function that depends on total ...
instax's user avatar
  • 11
1 vote
1 answer
228 views

Eigenvalue problem constrained with a penalty method

I am trying to constrain an eigenvalue problem. I am aware of the method utilizing the nullspace of the constraint vectors but I was wondering if it would be to use a penalty method for the same ...
user1941126's user avatar
1 vote
0 answers
349 views

SLSQP solver scipy with linear subset constraints

I have been trying to solve a least squares problem of the following form: $$ \begin{equation} \min_{\vec{x}} \frac{1}{2} \lVert f(\vec{x}) - f_{\text{target}} \rVert_{2}^2 + \alpha\Big( \frac{1-\rho}{...
bfg's user avatar
  • 11
1 vote
0 answers
341 views

the augmented global stiffness matrix is not positive semi-definite using Lagrange Multipliers method within FEM

The augmented global stiffness matrix is not positive semi-definite when using Lagrange Multipliers method to enforce boundary constraints on a simple square domain of integral form: I am considering ...
Wenjin Xing's user avatar
1 vote
0 answers
203 views

Maxwellian distribution of velocities with Shake algorithm present

I am writing a code to perform hybrid monte carlo molecular dynamics. To do this, I need to have a code to initialize the velocities of all particles according to a maxwell distribution. The code is ...
user3225087's user avatar
1 vote
0 answers
55 views

Numerical Implementation of "integrates to some values" type constraint in convex solvers?

I am maximizing a linear functional subject to an integrates to one constraint. More explicitly, my problem is $$\begin{align} &\max_{x \in \mathbb{R}^n}\quad c \cdot x\\ &\text{subject to} \...
Robert Bassett's user avatar
0 votes
1 answer
864 views

Solve integral equation for unknown constant

Consider the equations $$\int_0^L \mathbf W(\mathbf u, s) \, \mathrm ds = \mathbf 0$$ where $0 \leq s \leq L$ and $\mathbf u$ is a vector of constants. Numerically, what is the best way to ...
namu's user avatar
  • 187
0 votes
1 answer
1k views

Defining a soft constraint in cvxpy

I am using cvxpy to do a simple portfolio optimization. I implemented the following dummy code ...
ThatQuantDude's user avatar