# forum.alglib.net

ALGLIB forum
 It is currently Sat Apr 01, 2023 3:42 am

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: getting started with Linear (or Quadratic) ProgrammingPosted: Wed Apr 13, 2022 3:59 pm

Joined: Wed Apr 13, 2022 3:09 pm
Posts: 2
Please point me to relevant examples and/or APIs in ALGLIB.

I want to find the vector x whose objective function
• minimizes th L1 distance of x from a constant vector x0
• where L1 distance = sum of absolute values = sum abs((x(i)-x0(i))

and subject to this set of linear constraints:
• x(i+1) - x(i) >= constant(i) for i = 1..n-1 (i.e. x values in ascending order, with specified minimum spacing)
• x(1) >= min_constant
• x(n) <= max_constant

If I can get this working, then I want to try alternative distance metrics
• L2 distance = sum of squared differences = sum (x(i)-x0(i)**2
• L-infinity distance = max of absolute values = max abs((x(i)-x0(i))

Eventually, I want to extend the problem to two dimensions, with each x a point in the x-y plane.

Top

 Post subject: Re: getting started with Linear (or Quadratic) ProgrammingPosted: Thu Apr 14, 2022 11:54 pm

Joined: Wed Apr 13, 2022 3:09 pm
Posts: 2
I studied the manual and think I found the right examples:
For the L1 distance objective function which is discontinuous I will try:
Nonsmooth nonlinearly constrained optimization
https://www.alglib.net/translator/man/manual.cpython.html#example_minns_d_nlc

For the L2 distance objective function which is quadratic I will try:
https://www.alglib.net/translator/man/manual.cpython.html#example_minqp_d_lc1

Top

 Post subject: Re: getting started with Linear (or Quadratic) ProgrammingPosted: Fri Jul 15, 2022 3:20 pm

Joined: Fri Jul 15, 2022 2:24 pm
Posts: 3
I think L1 norm minimization can be cast as a linear programming problem.

Create non-negative dummy variables e_0l, e_0r, e_1l, e_1r, ...
then set equality constraints (in additional to the original constraints):
x(0) = x0(0) + e_0r
x(0) = x0(0) - e_0l
......

Then minimize e_0l + e0r + e_1l + e_1r + ...

So the LP example so be sufficient:
https://www.alglib.net/translator/man/manual.cpp.html#example_minlp_basic

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: