2

I have a physical system which can be modelled as

$$Ax+By+C=0$$

I have thousands of measurements of $x$ and $y$ from the physical system (includes some noise). I want to optimize for $A$, $B$, and $C$.

More Details: $A$, $B$, and $C$ are composed of other variables which are constrained, and are the real "goal".

$$A = v_1^2 + v_1$$ $$B = v_1^2$$ $$C = v_1^2 (v_2+v_3) + v_1 v_2 + v_2 +v_3$$ $$-\pi/4 \leq v_1 \leq \pi/4$$ $$-100 \leq v_2, v_3 \leq 100$$

I would like to do this in Java (1st choice) or c++ (2nd choice). I've found many (non)linear optimization and regression package, but the vocabulary is going over my head as to find the proper way (and therefore library+codepath) to approach solving this.

Budenn
  • 763

2 Answers2

0

Assuming $B \neq 0$, you can rewrite this as

$$y = A'x+C'$$

Now, you can use a least square linear regression to find the "best" value of $A'= \frac{A}{B}$ and $C'= \frac{C}{B}$

Tryss
  • 14,310
  • It's very possible v1 ~= 0. Most often, v1 will probably be small. Given that taking A/B when v1 is small makes a "small number over a small number" is it possible this could cause instability in a numerical solver? Is there a way we don't have to take this ratio? – user2025983 Aug 07 '15 at 11:50
  • @user2025983 : Just plot your data, if the cloud of points form a vertical "line", divide by $A$ instead, and use least square method on $x = B'y +C'$. If it's not a "line", then your modelisation by $Ax+By+C=0$ is not good – Tryss Aug 07 '15 at 12:12
0

The problem is not so simple if both $X$ and $Y$ are subject to errors. If this is the case, I should minimize $$\Phi(v_1,v_2,v_3)=\sum_{i=1}^n \Big(A(v_1,v_2,v_3)x_i+B(v_1,v_2,v_3)y_i+C(v_1,v_2,v_3)\Big)^2$$ In order to remove the bound constraints, I should rewrite $$v_i=v_i^{min}+\frac{v_i^{max}-v_i^{min}}{1+e^{-\phi_i}}$$ and use the $\phi_i$ as tuning parameters (which are now unbounded). For sure, the problem is to guess reasonable starting values but a preliminary standard linear regression $$y=\alpha x+\beta$$ immediately gives an estimate of $v_1$ since $$\alpha=-1-\frac 1 {v_1}$$ $$v_1=-\frac{1}{\alpha +1}$$ On the other hand, since $$\beta=-\frac {(v_1^2+1)(v_2+v_3)+v_1v_2}{v_1^2}$$ may be you could assume $v_2=v_3$ and extract $$v_2=v_3=-\frac{v_1^2 }{2 v_1^2+v_1+2}\beta$$ then the $\phi_i$'s from definition and, with all of that, start a minimization process using the corresponding $\phi_i$'s as variables.

Otherwise, perform the minimization with bound constraints.