1

Edit: Thanks for edit :-)

Can I ask please, how to maximize
$$\sum ({v_3 \text{sign}({xv_1+yv_2)}})\quad\text{where}$$ (edit: sum of i in 1..1000 ... 1 to length(v1) .. 3 vectors of same length $$\sum_{i=1}^n ({v_3[i] \text{sign}({xv_1[i]+yv_2[i])}})\quad\text{where}$$

$v1,v2,v3,\cdots\space $-vector(s) are real numbers, generated around $0\space$ [x,y=...value(s)] to find

I even don't how to partially derivate it... that signum function

I need find vales $(x,y)$. (in future I will try to use $n$ number of vectors, but solution for $2$ is best start. For one vector it's easy but for $2$ vectors - high mathematician skill required)

thanks a lot if somebody know how to solve it

1 Answers1

1

I don't there exists as a closed form solution of this. So there might not be a formula that expresses the optimal solution.

However you express your problem as Quadratically Constrained Linear Program.

First we introduce a vector of dummy variables $s$ and rewrite our objective as: $$\max \sum_i v_3[i]s[i]$$ subject to some additional constraints. We observer that $s$ has to have the same values as $\text{sign}$ term: $\forall i: \ s[i] \in \{-1,0,1\}$. This can be expressed as the constraint $s^2 = s^4$ which can be expressed as two quadratic constraints by yet another vector of dummy variables $j$. So we now got the constraints: $$j[i] = s[i]^2$$ $$j[i]^2 = s[i]^2$$

Please observe that the value of $xv_1[i]+yv_2[i]$ is irrelvant only the sign matters, so we loose no information by constraining it's value to be $\in \{-1,0,1\}$. Using this we can formulate this constraint:

$$s[i] = x*v_1[i] + y*v_2[i]$$

The following QCLP gives you your solution: $$\max_{s[1],...,s[n],j[1],...,j[n],x,y} \sum_{i=1}^n v_3[i]s[i]$$ subject to

$$\forall i \in \{1, ..., n\}: \ j[i] = s[i]^2$$ $$\forall i \in \{1, ..., n\}: \ j[i]^2 = s[i]^2$$ $$\forall i \in \{1, ..., n\}: \ s[i] = x*v_1[i] + y*v_2[i]$$

There is a large array of programs that can solve QCLP some of them might also be callable from R.

  • hello and thanks alot . if it cant be done by mathematics, i mean : i was looking for exact solution. i was inspired by weighted ordinary least squares formula(s) . but thanks alot, if there is no way how get maximum value of function & parameters (x,y), its helpful to me that it cant be done via math. thanks alot – user2120 Jan 16 '21 at 20:40
  • @user2120 I understand your problem now. I don't think there is a formula that gives you the right solution. However i put your problem into a common form in mathematical optimization. Using this standard form you can call dedicated solvers which can quickly find an exact solution. Does the answer make sense for you? – worldsmithhelper Jan 16 '21 at 21:14
  • well, at first i was happy for proof there is no math solution. then i was surprised in good way of modeling solution for solver. but now, when i did read it 2 times i understand it. i will need day-two to implement / test it.. for now i can only say thank you, thank you alot a wish you all best .. thank you :-) – user2120 Jan 16 '21 at 21:29
  • If you have any questions let me know. I am not familiar with R but i am familiar with Julia. – worldsmithhelper Jan 16 '21 at 21:50
  • hello, i found & install/run solver in R for quadratic function and quadratic constraints. but i got stuck with many many things how to write that model. (tried to run chat here on stackex but didnt find direct messages yet) .. I can create "an answer" here as "empty structure in R" and link good docs - would you have will to help to completed it ? but i dunno what to offer as return – user2120 Jan 17 '21 at 15:32
  • Can you give the name of solver you choose in R? – worldsmithhelper Jan 17 '21 at 15:42
  • optiSolve https://www.rdocumentation.org/packages/optiSolve/versions/0.1.2/topics/optiSolve-package – user2120 Jan 17 '21 at 15:43