- You are trying to maximize (\sum_{i=1}^{n} \log(v_i)). This is a concave function, so you should be minimizing the negative of this function, which you correctly attempted by setting prob.c = -ones(n, 1). However, looks like MOSEK handles exponential cones in a specific way, which requires setting up the problem to fit within the exponential cone framework.
- The logarithm can be represented using exponential cones. The primal exponential cone constraint in MOSEK requires that for each (i), variables ( (x_i, y_i, z_i) ) must satisfy ( y_i \exp(x_i/y_i) \leq z_i ). For your problem, this can be transformed into the cone constraints needed to represent (\log(v_i)).
Optimization problem with Mosek
21 次查看(过去 30 天)
显示 更早的评论
I want to solve the following problem: Maximize \sum_{i=1}^{n} \log(v_i) subject to v_i \geq 0 and A' v \leq n 1_m, where A is a n \times m matrix of positive reals, using Mosek in Matlab. This is my code:
n = 10; % Number of variables
m = 20; % Number of constraints
F = rand(n, m)*100; % Example n x m matrix of positive reals
A = F'; % Transpose of F for the constraint matrix
b = n * ones(m, 1); % Right-hand side for constraints
% Optimization problem
prob.c = -ones(n, 1); % Coefficients for the objective function (maximize sum log(v_i))
prob.a = sparse(A); % Constraint matrix A'
prob.blc = -inf(m, 1); % Lower bounds
prob.buc = b; % Upper bounds
% Lower bounds (v >= 0)
prob.blx = zeros(n, 1); % Lower bounds for v
prob.bux = inf(n, 1); % No upper bounds for v
% Exponential cone constraints for log(v_i)
prob.cones.type = 'pexp'; % Type of cone (primal exponential)
prob.cones.sub = (1:n); % Indices of the variables involved in the cone
prob.cones.dim = repmat(3, n, 1); % Each cone has dimensionality 3
% Call MOSEK optimizer to solve the problem
[r, res] = mosekopt('minimize', prob);
I tried a few variants, but so far I always get error 1200. Any help?
0 个评论
回答(1 个)
Manikanta Aditya
2024-10-10
Hello,
I think the error 1200 in Mosek typically indicates an issue with the problem formulation or the input data.
You want to maximize ∑i=1nlog(vi) subject to vi≥0 and A′v≤n1m, where A is an n×m matrix of positive reals.
Try out this, should help you get started:
n = 10; % Number of variables
m = 20; % Number of constraints
F = rand(n, m) * 100; % Example n x m matrix of positive reals
A = F'; % Transpose of F for the constraint matrix
b = n * ones(m, 1); % Right-hand side for constraints
% Initialize the problem structure
prob.c = zeros(3*n, 1); % Objective coefficients
prob.c(2:3:end) = -1; % Coefficients for maximizing log(v_i)
% Constraint matrix
prob.a = sparse([A, zeros(m, 2*n)]); % Augment A with zeros for auxiliary variables
prob.blc = -inf(m, 1); % Lower bounds for linear constraints
prob.buc = b; % Upper bounds for linear constraints
% Bounds for variables
prob.blx = [zeros(n, 1); -inf(2*n, 1)]; % v_i >= 0, no bounds on auxiliary variables
prob.bux = inf(3*n, 1); % No upper bounds
% Exponential cone constraints
prob.cones.type = repmat('PEXP', n, 1); % Type of cone (primal exponential)
prob.cones.sub = reshape(1:3*n, 3, n)'; % Indices for each cone
prob.cones.sub = prob.cones.sub(:); % Flatten to column vector
prob.cones.dim = repmat(3, n, 1); % Each cone has dimension 3
% Call MOSEK optimizer to solve the problem
[r, res] = mosekopt('minimize', prob);
Hope this helps.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!