필터 지우기
필터 지우기

Using Optimization toolbox in nonlinear with matrix manipulation

조회 수: 2 (최근 30일)
Yossi
Yossi 2017년 1월 4일
댓글: Yossi 2017년 1월 7일
I'm looking for optimization problem as follows that I don't know how to optimize it through Matlab Code or toolbox.
I have a minimum costs problem
The Parameters are follows:
BidPrices=[4735,4730,4727;410,409.7,409;59,58.8,58.5]; % Parameters which include 3 bid prices columns for 3 securities.
BidQuantity=[7000,2500,1081;320,1500,25000;754000,20000,101026]; % Bid Quantity for each bid
OpenPrice=[4735 ;410 ;59.1] % The open Price
Weights=[0.5;0.25;0.25]
Quantity=zeros(3:3) % variable to minimize
f=Qunatity*BidPrices % The function to minimize
The constraints are:
% Positive nonzero interger quantity
Quantity>=0
Quantity=Integer
% Quantity cannot exceed its bid quantity
Quantity(:,1)<=BidQuantity(:,1);
Quantity(:,2)<=BidQuantity(:,2);
Quantity(:,3)<=BidQuantity(:,3);
% The total change in the index from OpenPrice is higher than 1%
% First Step: Define active price matrix because when the quantity from bid1 to bid2 also change the price of the index
for I=1:length(OpenPrice)
if Quantity(I,1)>0 && Quantity(I,2)>0
EffectivePrice(I,1)=0
else
EffectivePrice(I,1)=0
end
if EffectivePrice(I,1)==0 && Quantity(I,2)==0 && Quantity(I,3)==0
EffectivePrice(I,2)=0
else
EffectivePrice(I,2)=0
end
if EffectivePrice(I,1)==0 && Quantity(I,3)>0
EffectivePrice(I,3)=1
else
EffectivePrice(I,3)=0
end
end
% Step 2: Defining the Constraint
Constraint=((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights))-1<=0.01
% How to write it correctly in Matlab code so that matlab can solve it? I didn't succeed with the toolbox.
  댓글 수: 1
Matt J
Matt J 2017년 1월 5일
f=Qunatity*BidPrices % The function to minimize
This is a 3x3 matrix-valued quantity, so it is not clear what it means to "minimize" it

댓글을 달려면 로그인하십시오.

답변 (2개)

Matt J
Matt J 2017년 1월 4일
You would use INTLINPROG in the Optimziation Toolbox
  댓글 수: 9
Walter Roberson
Walter Roberson 2017년 1월 5일
Any matrix of variables will be either rejected by the algorithm or reshaped into a vector, depending on which routine you are using.
Yossi
Yossi 2017년 1월 5일
Can you please help me to demonstrate how to rephrase the last constraint (of the limitation of 1%)

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2017년 1월 5일
You have
Constraint=((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights))-1<=0.01
and at any one point, EffectivePrice is the vector of trial values and BidPrices and Weights and OpenPrice are inputs.
So start doing some algebra:
((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights))-1<=0.01
impies
((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights)) <= 1.01
implies
((EffectivePrice*BidPrices*Weights) <= 1.01 * (OpenPrice*Weights)
implies
EffectivePrice <= 1.01 * (OpenPrice*Weights) / (BidPrices*Weights)
Everything on the right hand side is known in advance, so it can be computed as an upperbound.
Now at this point we run into the problem that OpenPrice and Weights are both 3 x 1 so you cannot "*" them together. If we guess that the formula should be
1.01 * (OpenPrice.*Weights) / (BidPrices*Weights)
then we get
ans =
0.505346858984519 0 0
0.0218787974850742 0 0
0.00315374861309241 0 0
Now as we go back through the code we can see that EffectivePrice is a binary variable, value 0 except in the case EffectivePrice(I,1)==0 && Quantity(I,3)>0 . And we can see that all of the constraint values are either 0 or a value less than 1. With the value required to be binary, this tells us that EffectivePrice must be identically 0.
This analysis assumes that when you write
Constraint=((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights))-1<=0.01
that even though ((EffectivePrice*BidPrices*Weights)/(OpenPrice*Weights)) is a 3 x 3 matrix, that you want the "-1" to be applied to all 9 entries. The calculations become different if the "-1" should instead be eye(3)
... You still have not explained how you can "minimize" f=Qunatity*BidPrices which is 3 x 3
  댓글 수: 1
Yossi
Yossi 2017년 1월 7일
In the "EffectivePrice", the condition is that the second bid should be effective only after the quantity of the first bid is filled. Hence, I'm not sure if the condition in RHS is a true constraint. Regarding the minimization of the function, I want that the cost of changing the price by 1% (which costs money when buying the first, second, third bid), would be minimized. Did I write this wrong?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by