fmincon objective function one know input matrix and one decision variable matrix
Show older comments
hello
my function's input are two matrice x and z and i want to find the optimal value of x given value of z
How can i write the fmincon code? with one unknow decision variable matrix and another given value input matrix?
function [ y ] = expectedprofit(x,z)
k = x(1);
s = x(2);
potential_arrival_rate = z(1);
mu = z(2);
c = z(3);
K = z(4);
lambda=potential_arrival_rate*s;
rho=lambda/mu;
%%m/m/k queueing waiting time
h=0;
for t=0:k-1
h=h+power(rho,t)/factorial(t);
end;
f=1; %factorial of k ('k!')
for m=1:k
f=f*m;
end;
denominator = h+k*power(rho,k)/[(k-rho)*f];
numerator = k*power(rho,k)/[(k-rho)*f];
C = numerator/denominator;
waitingtime = C/[mu*(k-rho)];
%%platform expected revenue
y=-lambda*[1-s-c*waitingtime-power(k,2)/(K*lambda)];
end
my fmincon code is:
fun = @expectedprofit;
x0 = [100,0.1];
A = [-1,100];
b = 0;
Aeq = [];
beq = [];
lb = [0,0];
ub = [100,1];
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub);
Answers (1)
Alan Weiss
on 13 Mar 2017
Without reading your code in detail, if z is given (numeric) and you want to find x, then have your objective function be
fun = @(x)expectedprofit(x,z);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!