I am getting a max depth level error when optimizing a polynomial. In the output below, I noticed that the LP iterations seem to stop. Why would scip branch on a lot of variables and never call the LP solver again? I am running it with Ipopt.
I cannot try to increase the max depth level because it is #defined to be 65535, and I do not want to rebuild scip.
Below is my input file and output.
$cat mytest.pip
Maximize
obj:5 x1^1*x2^1*x3^1*x7^1*x8^1*x18^1*x19^2 + 3 x1^1*x2^1*x3^1*x10^1*x13^1*x15^1*x19^2 - 6 x1^1*x4^1*x11^1*x15^1*x18^2*x19^2 + 8 x2^3*x4^1*x8^1*x11^1*x14^2 + 9 x2^1*x3^1*x9^1*x11^1*x13^1*x17^2*x18^1 - 3 x4^1*x8^1*x12^1*x14^1*x17^1*x18^2*x20^1 + 1 x5^3*x6^2*x9^1*x18^1*x20^1 - 6 x5^2*x8^1*x16^4*x17^1 + 10 x6^1*x8^1*x15^3*x16^2*x19^1 + 10 x9^1*x12^1*x14^1*x15^1*x16^2*x19^2
Bounds
1 <= x1 <= 150
1 <= x2 <= 150
1 <= x3 <= 150
1 <= x4 <= 150
1 <= x5 <= 150
1 <= x6 <= 150
1 <= x7 <= 150
1 <= x8 <= 150
1 <= x9 <= 150
1 <= x10 <= 150
1 <= x11 <= 150
1 <= x12 <= 150
1 <= x13 <= 150
1 <= x14 <= 150
1 <= x15 <= 150
1 <= x16 <= 150
1 <= x17 <= 150
1 <= x18 <= 150
1 <= x19 <= 150
1 <= x20 <= 150
Integers
x1
x2
x3
x4
x5
x6
x7
x8
x9
x10
x11
x12
x13
x14
x15
x16
x17
x18
x19
x20
End
$ ./scip -f mytest.pip
SCIP version 3.1.0 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: SoPlex 2.0.0] [GitHash: 577ee45]
Copyright (c) 2002-2014 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)
External codes:
Readline 6.3 GNU library for command line editing (gnu.org/s/readline)
SoPlex 2.0.0 Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: 568f354]
cppad-20140000.1 Algorithmic Differentiation of C++ algorithms developed by B. Bell (www.coin-or.org/CppAD)
ZLIB 1.2.8 General purpose compression library by J. Gailly and M. Adler (zlib.net)
GMP 5.1.3 GNU Multiple Precision Arithmetic Library developed by T. Granlund (gmplib.org)
ZIMPL 3.3.2 Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)
Ipopt 3.11.9 Interior Point Optimizer developed by A. Waechter et.al. (www.coin-or.org/Ipopt)
user parameter file <scip.set> not found - using default parameters
read problem <mytest.pip>
============
original problem has 21 variables (0 bin, 20 int, 0 impl, 1 cont) and 1 constraints
solve problem
=============
feasible solution found by trivial heuristic after 0.0 seconds, objective value 1.000000e+05
presolving:
(round 1) 0 del vars, 0 del conss, 0 add conss, 1 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 2) 0 del vars, 0 del conss, 0 add conss, 2 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 3) 0 del vars, 0 del conss, 55 add conss, 2 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 4) 0 del vars, 0 del conss, 55 add conss, 2 chg bounds, 0 chg sides, 0 chg coeffs, 56 upgd conss, 0 impls, 0 clqs
(round 5) 3 del vars, 3 del conss, 55 add conss, 73 chg bounds, 0 chg sides, 0 chg coeffs, 56 upgd conss, 0 impls, 0 clqs
(round 6) 3 del vars, 3 del conss, 55 add conss, 102 chg bounds, 0 chg sides, 0 chg coeffs, 57 upgd conss, 0 impls, 0 clqs
(round 7) 3 del vars, 3 del conss, 55 add conss, 107 chg bounds, 0 chg sides, 0 chg coeffs, 57 upgd conss, 0 impls, 0 clqs
presolving (8 rounds):
3 deleted vars, 3 deleted constraints, 55 added constraints, 107 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
0 implications, 0 cliques
presolved problem has 73 variables (0 bin, 20 int, 52 impl, 1 cont) and 53 constraints
12 constraints of type <abspower>
41 constraints of type <quadratic>
Presolving Time: 0.04
time | node | left |LP iter|LP it/n| mem |mdpt |frac |vars |cons |cols |rows |cuts |confs|strbr| dualbound | primalbound | gap
0.1s| 1 | 0 | 47 | - | 447k| 0 | 1 | 73 | 53 | 73 | 190 | 0 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.1s| 1 | 0 | 48 | - | 480k| 0 | 1 | 73 | 54 | 73 | 191 | 1 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 0 | 49 | - | 481k| 0 | 1 | 73 | 54 | 73 | 192 | 2 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 0 | 50 | - | 483k| 0 | 1 | 73 | 54 | 73 | 193 | 3 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 0 | 51 | - | 484k| 0 | 1 | 73 | 54 | 73 | 194 | 4 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 0 | 52 | - | 486k| 0 | 1 | 73 | 54 | 73 | 195 | 5 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 0 | 53 | - | 487k| 0 | 1 | 73 | 54 | 73 | 196 | 6 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 1 | 2 | 171 | - | 502k| 0 | 1 | 73 | 54 | 73 | 196 | 6 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 100 | 101 | 479 | 4.3 | 566k| 98 | 0 | 73 | 54 | 73 | 164 | 139 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.2s| 200 | 201 | 774 | 3.6 | 669k| 198 | 0 | 73 | 54 | 73 | 237 | 241 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
0.5s| 300 | 301 | 1070 | 3.4 | 831k| 271 | 0 | 73 | 54 | 73 | 86 | 410 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.6s| 400 | 402 | 1077 | 2.6 | 884k| 271 | 0 | 73 | 54 | 73 | 87 | 412 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.6s| 500 | 502 | 1077 | 2.1 | 929k| 271 | 0 | 73 | 54 | 73 | 87 | 412 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.6s| 600 | 602 | 1077 | 1.7 | 973k| 326 | 0 | 73 | 54 | 73 | 87 | 412 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
0.6s| 700 | 702 | 1077 | 1.5 |1020k| 426 | 0 | 73 | 54 | 73 | 87 | 412 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
...
9.4s| 65800 | 65802 | 1079 | 0.0 | 30M| 65k| 0 | 73 | 54 | 73 | 87 | 412 | 0 | 0 | 1.178930e+19 | 1.000000e+05 | Large
[src/scip/tree.c:777] ERROR: maximal depth level exceeded
[src/scip/tree.c:969] ERROR: Error <-16> in function call
[src/scip/tree.c:5268] ERROR: Error <-16> in function call
[src/scip/tree.c:5514] ERROR: Error <-16> in function call
[src/scip/scip.c:30672] ERROR: Error <-16> in function call
[src/scip/branch_pscost.c:610] ERROR: Error <-16> in function call
[src/scip/branch.c:1581] ERROR: Error <-16> in function call
[src/scip/branch.c:2503] ERROR: Error <-16> in function call
[src/scip/solve.c:3863] ERROR: Error <-16> in function call
[src/scip/solve.c:4312] ERROR: Error <-16> in function call
[src/scip/scip.c:13633] ERROR: Error <-16> in function call
[src/scip/scipshell.c:98] ERROR: Error <-16> in function call
[src/scip/scipshell.c:284] ERROR: Error <-16> in function call
[src/scip/scipshell.c:332] ERROR: Error <-16> in function call
SCIP Error (-16): maximal branching depth level exceeded
first of all thanks for submitting this problem. We have identified two major problems.
Your model seams to be numerically unstable because after some iterations some variable bounds are set to something with the magnitude of 1^{13} before and 1^{-4} behind the comma. In floating point arithmetic there are 15-16 significant signs. Thats why using 'ceil' and 'floor' functions may produce unpredictable results. Currently we are not sure how to handle this, but we are working on it. At this point, you can try to change the precisions by changing the parameters for the numerics, e.g.,
numerics/epsilon and numerics/hugeval.
After some iterations the variable bounds are in the magnitude of 1^{13}. In particular, SCIP branches in each iteration on the same variable and the lower bound increase by exactly one. In other words, SCIP performs probably a depth-first-search and since the range of your integral variables x_{i} is 150, the range of the variables that are introduced to replace the products in your polynomial increase to 11390625000000. Obviously, SCIP runs into the depth limit.
Moreover, due to the numerical troubles mentioned above, SCIP does not recognize bound changes after branching on some variables in one of the nodes. If SCIP selects this node the LP does not need to be solved again.
If you have improved your model feel free to post it again or send us an email to the SCIP mailing-list.
Kind regards,
Jakob
Related
I apologize in advance if the question is too basic. Window functions are fun and challenging at the same time!
I have two Postgres tables such as below called client and order.
id | name
------------
41 | james
29 | melinda
36 | henry
...
id | date | volume | client_id
------------------------------
328 | 2018-01-03 | 16 | 41
411 | 2018-01-29 | 39 | 29
129 | 2018-01-13 | 73 | 29
542 | 2018-01-22 | 62 | 36
301 | 2018-01-17 | 38 | 41
784 | 2018-01-08 | 84 | 29
299 | 2018-01-10 | 54 | 36
300 | 2018-01-10 | 18 | 36
178 | 2018-01-30 | 37 | 36
...
a) How can I write a query to find the largest difference in order volume for each client? For example, client_id = 36 should show (54 + 18) - 37 = -35. This is because orders placed on the same day by the same client should count as one order.
b) How can I find the difference in volume between the two most recent orders for each client? For example, client_id = 29 should show 39 - 73 = -34
Well here is a T-SQL.
For this formula as you said ---> Max(total volume each day) - Min(total volume each day)
May help you.
SELECT (X.Max(SumV)-X.Min(SumV))
From (
SELECT Client_Id,Date,SUM(Volume) AS SumV
FROM Orders
GROUP BY Client_id,Date
) X
Group by X.Client_Id
I have 2 tables shown below:
Table 1
Student ID - DATE_NO - SCORE
Table 2
STUDENT_ID - DATE_NO - HT - WT
Table 1 has the physical test scores and the date of the test for each student while Table 2 lists their height (HT) and weight (WT) and the date they were measured.
Example Data:
Table 1
Student ID | DATE_NO | SCORE |
125 | 3 | 90 |
572 | 6 | 75 |
687 | 11 | 95 |
Table 2
Student_ID | DATE_NO | HT | WT |
125 | 2 | 70 | 150 |
125 | 3 | 72 | 155 |
125 | 6 | 72 | 160 |
572 | 2 | 70 | 200 |
572 | 5 | 70 | 225 |
572 | 8 | 70 | 215 |
572 | 9 | 70 | 220 |
687 | 4 | 65 | 140 |
687 | 7 | 67 | 150 |
687 | 11 | 70 | 155 |
687 | 12 | 67 | 160 |
I am not guaranteed to have the exact same DATE_NO for both HT/WT and the Test score date. I want the most recent HT and WT for each student when they took their physical test. Based on the example data above, the optimal join would give me the table below:
Modified Table 1
Student ID | DATE_NO | HT | WT |
125 | 3 | 72 | 155 |
572 | 6 | 70 | 225 |
687 | 11 | 70 | 155 |
I'd like to use the UPDATE statement on Table 1, so after altering Table 1 with HT int and WT int, I attempt to do the following:
UPDATE T1
SET HT = T2.HT, WT = T2.WT
FROM Table_1 as T1
INNER JOIN Table_2 AS T2 ON T1.STUDENT_ID = T2.STUDENT_ID
WHERE (T1.DATE_NO) >= (T2.DATE_NO)
But the result gives me the FIRST record that meets the criteria. Switching greater than to less than [ >= to <= ] Make the HT/WT for each student the entries for Month 6,8, and 12) when it should be month 3,8, and 11. Any suggestions?
FYI: Won't be able to apply any solutions till Friday.
Is it something like this you're looking for:
UPDATE Q
SET
T1_HT = T2_HT
, T1_WT = T2_WT
FROM
(
SELECT
T1.HT T1_HT
, T1.WT T1_WT
, T2.HT T2_HT
, T2.WT T2_WT
, ROW_NUMBER() OVER (PARTITION BY T1.STUDENT_ID ORDER BY T2.DATE_NO DESC) R
FROM
Table_1 T1
JOIN Table_2 T2 ON
T1.STUDENT_ID = T2.STUDENT_ID
AND T2.DATE_NO <= T1.DATE_NO
) Q
WHERE R = 1
SELECT ts.student_id,
ts.date_no,
hw.ht,
hw.wt
FROM test_scores ts,
ht_wt hw
WHERE hw.student_id = ts.student_id
AND hw.date_no <= ts.date_no
AND hw.date_no =
(SELECT max(date_no)
FROM ht_wt
WHERE date_no <= ts.date_no
AND student_id = ts.student_id)
sql fiddle here
Hello there i have this example dataset:
employee_id | amount | cumulative_amount
-------------+------------+-----------------
2 | 100 | 100
6 | 220 | 320
7 | 45 | 365
8 | 50 | 415
9 | 110 | 525
16 | 300 | 825
17 | 250 | 1075
18 | 200 | 1275
And interval, let's say 300:
I'd like to pick only rows, that match the interval, with condition:
Pick value if it's >= previous value+interval
(e.g if start Val = 100, next matching row is where cumulative amount >= 400, and so on)
:
employee_id | amount | cumulative_amount
-------------+------------+-----------------
2 | 100 | 100 <-- $Start
6 | 220 | 320 - 400
7 | 45 | 365 - 400
8 | 50 | 415 <-- 1
9 | 110 | 525 - 715 (prev value (415)+300)
16 | 300 | 825 <-- 2
17 | 250 | 1075 - 1125 (825+300)
18 | 200 | 1275 <-- 3
so final result would be :
employee_id | amount | cumulative_amount
-------------+------------+-----------------
2 | 100 | 100
8 | 50 | 415
16 | 300 | 825
18 | 200 | 1275
How to achieve this in PostgreSQL in most efficient way ?
Column cumulative_amount is progressive sum of column amount
and it's calculated in another query, which result is dataset above, table is ordered by employee_id.
Regards.
not saying it is the most effective way, but probably the easiest:
s=# create table s1(a int, b int, c int);
CREATE TABLE
Time: 10.262 ms
s=# copy s1 from stdin delimiter '|';
...
s=# with g as (select generate_series(100,1300,300) s)
, o as (select *,sum(b) over (order by a) from s1)
, c as (select *, min(sum) over (partition by g.s)
from o
join g on sum >= g.s and sum < g.s + 300
)
select a,b,sum from c
where sum = min
;
a | b | sum
----+-----+------
2 | 100 | 100
8 | 50 | 415
16 | 300 | 825
17 | 250 | 1075
(4 rows)
here I used order by a as you sad your cumulative sum is by first column (which reconciled with third row)
I am trying to create a dummy variable to identify the next five observations after a selection of cutoffs. The first method in the code below works, but it looks a bit messy and I'd like to be able to adjust the number of observations I'm creating dummies for without typing out the same expression 30 times (usually a sign I'm doing something the hard way).
Every time I put a macro into the indexing, i.e.
[_n-`i']
I get the following error:
_= invalid name
r(198);
I'd be very grateful for some advice.
sysuse auto.dta, replace
global cutoffs 3299 4424 5104 5788 10371
This works
sort price
gen A=0
foreach x in $cutoffs {
replace A=1 if price==`x'
replace A=1 if price[_n-1]==`x'
replace A=1 if price[_n-2]==`x'
replace A=1 if price[_n-3]==`x'
replace A=1 if price[_n-4]==`x'
replace A=1 if price[_n-5]==`x'
}
This doesn't.
foreach x in $cutoffs {
forval `i' = 0/25 {
replace A=1 if price[_n-`i']==`x'
}
}
Any advice as to why?
In Stata terms no loops are needed here at all, except those tacit in generate and replace. You want to set a counter going each time immediately after you hit a cutoff, and then identify counter values between 1 and 5. Here's some technique:
sysuse auto.dta, clear
global cutoffs 3299,4424,5104,5788,10371
sort price
gen counter = 0 if inlist(price, $cutoffs)
replace counter = counter[_n-1] + 1 if missing(counter)
gen wanted = inrange(counter, 1, 5)
list price counter wanted
+---------------------------+
| price counter wanted |
|---------------------------|
1. | 3,291 . 0 |
2. | 3,299 0 0 |
3. | 3,667 1 1 |
4. | 3,748 2 1 |
5. | 3,798 3 1 |
|---------------------------|
6. | 3,799 4 1 |
7. | 3,829 5 1 |
8. | 3,895 6 0 |
9. | 3,955 7 0 |
10. | 3,984 8 0 |
|---------------------------|
11. | 3,995 9 0 |
12. | 4,010 10 0 |
13. | 4,060 11 0 |
14. | 4,082 12 0 |
15. | 4,099 13 0 |
|---------------------------|
16. | 4,172 14 0 |
17. | 4,181 15 0 |
18. | 4,187 16 0 |
19. | 4,195 17 0 |
20. | 4,296 18 0 |
|---------------------------|
21. | 4,389 19 0 |
22. | 4,424 0 0 |
23. | 4,425 1 1 |
24. | 4,453 2 1 |
25. | 4,482 3 1 |
|---------------------------|
26. | 4,499 4 1 |
27. | 4,504 5 1 |
28. | 4,516 6 0 |
29. | 4,589 7 0 |
30. | 4,647 8 0 |
|---------------------------|
31. | 4,697 9 0 |
32. | 4,723 10 0 |
33. | 4,733 11 0 |
34. | 4,749 12 0 |
35. | 4,816 13 0 |
|---------------------------|
36. | 4,890 14 0 |
37. | 4,934 15 0 |
38. | 5,079 16 0 |
39. | 5,104 0 0 |
40. | 5,172 1 1 |
|---------------------------|
41. | 5,189 2 1 |
42. | 5,222 3 1 |
43. | 5,379 4 1 |
44. | 5,397 5 1 |
45. | 5,705 6 0 |
|---------------------------|
46. | 5,719 7 0 |
47. | 5,788 0 0 |
48. | 5,798 1 1 |
49. | 5,799 2 1 |
50. | 5,886 3 1 |
|---------------------------|
51. | 5,899 4 1 |
52. | 6,165 5 1 |
53. | 6,229 6 0 |
54. | 6,295 7 0 |
55. | 6,303 8 0 |
|---------------------------|
56. | 6,342 9 0 |
57. | 6,486 10 0 |
58. | 6,850 11 0 |
59. | 7,140 12 0 |
60. | 7,827 13 0 |
|---------------------------|
61. | 8,129 14 0 |
62. | 8,814 15 0 |
63. | 9,690 16 0 |
64. | 9,735 17 0 |
65. | 10,371 0 0 |
|---------------------------|
66. | 10,372 1 1 |
67. | 11,385 2 1 |
68. | 11,497 3 1 |
69. | 11,995 4 1 |
70. | 12,990 5 1 |
|---------------------------|
71. | 13,466 6 0 |
72. | 13,594 7 0 |
73. | 14,500 8 0 |
74. | 15,906 9 0 |
+---------------------------+
In fact, your text says "the next five observations after" but your code implements not that only that, but the cutoff observation too. For the latter, use inrange(counter, 0, 5).
Understanding the principles explained here is crucial for this question.
For inrange() and inlist() see their help entries and/or this paper.
So, what did you do wrong?
This line
forval `i' = 0/25 {
in illegal unless you have previously defined the local macro i (and rather odd style even then). You perhaps meant
forval i = 0/25 {
although where the 25 comes from, given your problem statement, is unclear to me. The error message isn't especially helpful, but Stata is struggling to make sense of code with a hole in it, given that the local macro implied by your code is not defined.
Maybe is the title not clear enough, but didn't knew an better way to say it.
The thing is that I've got an table called Partij which has an idPartij and an Moederpartij. The column Moederpartij will point back to idPartij ( so we can create an Mother -> Child relation ).
This is the Query I have so far:
SELECT
P.idPartij,
P.Partijnaam,
P.Gewicht,
PER.Perceel,
P.Moederpartij
FROM Partij AS P
LEFT OUTER JOIN Perceel AS PER ON P.idPerceel = PER.idPerceel
WHERE P.Actief = 1
ORDER BY
P.Moederpartij ASC,
P.Partijnaam ASC
Which results in the following output:
360 | 34 Avarna 13-1V | | 0
280 | 36 Agata 13-1V | | 0
160 | 37 Excellency 13-1V | | 0
140 | 38 Erika 13-1V | | 0
300 | 39 Rosagold 13-1V | | 0
240 | 40 Fontane 13-2V | | 0
200 | 41 Fontane 13-1V | | 0
220 | 42 Fontane 13-3V | | 0
180 | 45 Spunta 13-3V | | 0
260 | 46 Arnova 13-1V | | 0
400 | 43 Spunta 13-2V | | 180
380 | 44 Spunta 13-1V | | 180
320 | 35 Altus 13-1V | | 260
340 | 47 Arizona 13-1V | | 260
But I'm trying to get the following output:
360 | 34 Avarna 13-1V | | 0
280 | 36 Agata 13-1V | | 0
160 | 37 Excellency 13-1V | | 0
140 | 38 Erika 13-1V | | 0
300 | 39 Rosagold 13-1V | | 0
240 | 40 Fontane 13-2V | | 0
200 | 41 Fontane 13-1V | | 0
220 | 42 Fontane 13-3V | | 0
180 | 45 Spunta 13-3V | | 0
400 | 43 Spunta 13-2V | | 180
380 | 44 Spunta 13-1V | | 180
260 | 46 Arnova 13-1V | | 0
320 | 35 Altus 13-1V | | 260
340 | 47 Arizona 13-1V | | 260
So that you first get the Mother (Moederpartij) And after that all the Childs, and so on...
Is this even possible in 1 single Query or should I loop in PHP through the records an get all the child for each record?
EDIT 1
The DB where this is running, is an MariaDB.
Try this one. I had added an column in the select query and sorted based on it. Since I don't have the MariaDB have not tested the query but I am sure it shld solve ur query.
SELECT
P.idPartij,
P.Partijnaam,
P.Gewicht,
PER.Perceel,
P.Moederpartij,
case when P.Moederpartij =0 then
Concat(P.idPartij ,"-", "0","-", P.idPartij )
else
Concat(P.Moederpartij ,"-", "9","-", P.idPartij )
end sorder
FROM Partij AS P
LEFT OUTER JOIN Perceel AS PER ON P.idPerceel = PER.idPerceel
WHERE P.Actief = 1
ORDER BY
sorder Asc
I am not sure if I understand your question, but is "Avarna 13-1V" for example the full party name, and the mother as you call it is "Avarna"?
I.e. you want all Spuntas, Fontanes etc. together but they also contain the 13-1V, 13-2V etc. and that's what throws it off?
You could order by just the first word first (locate the space separator & take the left of that), then by the mother party field. E.g. something like this:
ORDER BY LEFT(Partijnaam, LOCATE(' ',Partijnaam) - 1), Moederpartij
But if that is the case why not just separate the text name and the 13-v1 etc. into different columns?
(MySQL)