MrMarc

3163 Reputation

18 Badges

17 years, 135 days

MaplePrimes Activity


These are replies submitted by MrMarc

How do you solve a second order cone optimization problem with
the Optimization package in Maple?

@pagan Thank you for this!

One last question: Does there exit anyway that you can introduce a cardinal constraint
into the QP optimization ie give me the 5 largest long positions and the 5 largest short
positions.

The problem with long-short optimization is that a long position (+) automatically is canceled out
by a short position (-) so the w[1]+w[2]+w[i]=1 constraint has little effect.

@pagan Thank you for this!

One last question: Does there exit anyway that you can introduce a cardinal constraint
into the QP optimization ie give me the 5 largest long positions and the 5 largest short
positions.

The problem with long-short optimization is that a long position (+) automatically is canceled out
by a short position (-) so the w[1]+w[2]+w[i]=1 constraint has little effect.

Excellent stuff!
I would assume the best way is just to set assume = nonnegative
I also noted that if you set infolevel[Optimization]:=3 then I get:

QPSolve: final value of objective 12.8003935893719394

but the procedure output is :

 data1 := [-12.8003935893719, [w[1] = 0., w[2] = 0.472194472519205544,

   w[3] = 0., w[4] = 0., w[5] = 0., w[6] = 0.163881068564444177,

   ...........................

I assume that has to do with the fact that my objective function is:

Transpose(W).ER-Transpose(W).Q.W;

When the default objective function from the
Optimization[QPSolve](Matrix Form) help page is:

c' x + (1/2) x' H x

hummm, I wonder why it does not adjust for that?!

Excellent stuff!
I would assume the best way is just to set assume = nonnegative
I also noted that if you set infolevel[Optimization]:=3 then I get:

QPSolve: final value of objective 12.8003935893719394

but the procedure output is :

 data1 := [-12.8003935893719, [w[1] = 0., w[2] = 0.472194472519205544,

   w[3] = 0., w[4] = 0., w[5] = 0., w[6] = 0.163881068564444177,

   ...........................

I assume that has to do with the fact that my objective function is:

Transpose(W).ER-Transpose(W).Q.W;

When the default objective function from the
Optimization[QPSolve](Matrix Form) help page is:

c' x + (1/2) x' H x

hummm, I wonder why it does not adjust for that?!

thanks Robert! Well, I am not sure. I think we should use the LinearAlgebra package.
When mosek solves a soc problem then it solves the problem with 10-15 iterations
with an interior point solver. I think maple have some procedure for interior point solver.
Cant you solve a soc problem with linear programming?

Anyway the most important thing is that we understand the dynamics and how to set up
the problem. In the worst case we can to write the optimization algorithm in Maple. 

thanks Robert! Well, I am not sure. I think we should use the LinearAlgebra package.
When mosek solves a soc problem then it solves the problem with 10-15 iterations
with an interior point solver. I think maple have some procedure for interior point solver.
Cant you solve a soc problem with linear programming?

Anyway the most important thing is that we understand the dynamics and how to set up
the problem. In the worst case we can to write the optimization algorithm in Maple. 

can you rewrite the objective function so it becomes quadratic?

can you rewrite the objective function so it becomes quadratic?

PatrickT nice! What an effort :-) I had a quick look at the document it looks nice.
I will look at your document more in detail during the next 30 minutes.
I have posted my version (I think I managed to crack it. Robert solution was
to complicated for me) of the problem at the Maple application center:

http://www.maplesoft.com/applications/view.aspx?SID=99621


Why dont you post your document at the Application center as well?!
The more the merrier!

PatrickT nice! What an effort :-) I had a quick look at the document it looks nice.
I will look at your document more in detail during the next 30 minutes.
I have posted my version (I think I managed to crack it. Robert solution was
to complicated for me) of the problem at the Maple application center:

http://www.maplesoft.com/applications/view.aspx?SID=99621


Why dont you post your document at the Application center as well?!
The more the merrier!

Thank you for your input Robert :-) What do you think of the notion of solving a portfolio
optimization (maximize risk adjusted returns) problem this way?
ie given a 1000 security universe give me the 10 stocks with the best risk adjusted returns.
I know that Edouard Petrounevitch (http://www.optimset.com/portfolio/results.html)
algorithm can be used to solve such a problem however I dont have such Maple code yet.

 

I also noted that our two algorithms (mine and yours produce different results)

i) if you run my algorithm with:  con := 5:   w := [3, 2, 1]:    v := [5, 3, 4]:
Then you get:   [[Total value = 9], [Total weight = 4], selection = [1, 3]];

ii) if we run your algorithm with:   W := 5:  w := [3, 2, 1]:  v := [5, 3, 4]:  N := nops(w):
Then we get:   [Optimal value, 8, for total weight, 5, with selection, {1, 2}]

Since the total value is higher for i) this to me indicate that maybe your algorithm should have
>= instead of > somewhere..... what do you think of that?!


Thank you for your input Robert :-) What do you think of the notion of solving a portfolio
optimization (maximize risk adjusted returns) problem this way?
ie given a 1000 security universe give me the 10 stocks with the best risk adjusted returns.
I know that Edouard Petrounevitch (http://www.optimset.com/portfolio/results.html)
algorithm can be used to solve such a problem however I dont have such Maple code yet.

 

I also noted that our two algorithms (mine and yours produce different results)

i) if you run my algorithm with:  con := 5:   w := [3, 2, 1]:    v := [5, 3, 4]:
Then you get:   [[Total value = 9], [Total weight = 4], selection = [1, 3]];

ii) if we run your algorithm with:   W := 5:  w := [3, 2, 1]:  v := [5, 3, 4]:  N := nops(w):
Then we get:   [Optimal value, 8, for total weight, 5, with selection, {1, 2}]

Since the total value is higher for i) this to me indicate that maybe your algorithm should have
>= instead of > somewhere..... what do you think of that?!


hummm, when I run the code:   Knapsack(46, {1, 4, 12, 20, 38, 56});

why do I get the following error message:

Error, (in Knapsack) invalid input: member received `union`^2*(`union`*(`union`*(`union`*(`union`*({21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14}+{15}+{16}+{17}+{18}+{19}+{20}+{22}+{23}+{24}+{25}+{26}+{27}+{28}+{29}+{30}+{31}+{32}+{33}+{34}+{35}+{36}+{37}+{38}+{39}+{40}+{41}+{42}+{43}+{44}+{45}+{46})+(`union`+4)*(4+{21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14}+{15}+{16}+{17}+{18}+{19}+{20}+{22}+{23}+{24}+{25}+{26}+{27}+{28}+{29}+{30}+{31}+{32}+{33}+{34}+{35}+{36}+{37}+{38}+{39}+{40}+{41}+{42}+{43}+{44}+{45}+{46})+(`union`+8)*(8+{21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14...

hummm, when I run the code:   Knapsack(46, {1, 4, 12, 20, 38, 56});

why do I get the following error message:

Error, (in Knapsack) invalid input: member received `union`^2*(`union`*(`union`*(`union`*(`union`*({21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14}+{15}+{16}+{17}+{18}+{19}+{20}+{22}+{23}+{24}+{25}+{26}+{27}+{28}+{29}+{30}+{31}+{32}+{33}+{34}+{35}+{36}+{37}+{38}+{39}+{40}+{41}+{42}+{43}+{44}+{45}+{46})+(`union`+4)*(4+{21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14}+{15}+{16}+{17}+{18}+{19}+{20}+{22}+{23}+{24}+{25}+{26}+{27}+{28}+{29}+{30}+{31}+{32}+{33}+{34}+{35}+{36}+{37}+{38}+{39}+{40}+{41}+{42}+{43}+{44}+{45}+{46})+(`union`+8)*(8+{21}+{0}+{1}+{2}+{3}+{4}+{5}+{6}+{7}+{8}+{9}+{10}+{11}+{12}+{13}+{14...

First 13 14 15 16 17 18 19 Last Page 15 of 33