Error using "mskoptimset"

Hi. I want to use "surrogateopt" or "ga" to solve mixed-integer programming. But I got this error for both solvers. If someone could help me, I would greatly appreciate it.
"Error using mskoptimset
Expected argument 2 to be a string parameter name or an options structure
created with mskoptimset.
Error in linprog (line 138)"
My code is as follows:
Objconstr = @(phi) DL_Sum_Throughput (phi, P_DL_b_m, h_b_m, sigma2, K);
A_Eq1 = kron( ones(1,B) , eye(M) ); % Dim: M x BM
A_Eq2 = kron( ones(1,K) , eye(M) ); % Dim: M x KM
A_Eq3 = zeros(1,K); % Dim: 1 x K
A_Eq = blkdiag( A_Eq1 , A_Eq2, A_Eq3 ); % Dim: 2M+1 x M(B+K)
b_Eq = [ones(2*M,1) ; 0]; % Dim: 2M+1 x 1
A_InEq1 = kron( eye(B) , ones(1,M) ); % Dim: B x BM
A_InEq2 = 2 - kron( eye(K) , ones(1,M) ); % Dim: K x KM
A_InEq3 = zeros(1,K); % Dim: 1 x K
b_InEq1 = round(P_DL_b'./sum(P_DL_b) *M); % Dim: B x 1
b_InEq2 = zeros(K,1); % Dim: K x 1
A_InEq = blkdiag(A_InEq1 , A_InEq2, A_InEq3); % Dim: B+K+1 x M(B+K)
b_InEq = [b_InEq1 ; b_InEq2; 0]; % Dim: B+K+1 x 1
intcon = 1:1:M*(B+K); % Decision Variables that are integer-valued
lb = zeros(1,M*(B+K)+K);
ub = [ones(1,M*(B+K)) , ones(1,K)*W_Total];
% ub = [ones(1,M*(B+K) + K)];
%% Mixed Integer Surrogate Optimization
options_surr = optimoptions('surrogateopt','PlotFcn','surrogateoptplot','ConstraintTolerance',1e-6,...
'MaxFunctionEvaluations',200);
problem_surr = struct('objective',Objconstr,'lb',lb,'ub',ub,'intcon',intcon,...
'Aineq',A_InEq,'bineq',b_InEq,'Aeq',A_Eq,'beq',b_Eq,'options',options_surr,'solver','surrogateopt');
[x_surr, fval_surr, exitflag_surr, output_surr, trials_surr] = surrogateopt(problem_surr);

8 Comments

You state that the error message is:
"Error using mskoptimset
Expected argument 2 to be a string parameter name or an options structure
created with mskoptimset.
Error in linprog (line 138)"
This confuses me for several reasons. One is I am not familiar with the function mskoptimset. I believe that it is not a MathWorks function. The other is that there is an error reported from linprog, and I do not see a linprog call in your code.
Alan Weiss
MATLAB mathematical toolbox documentation
Thank you for your response. Yes, it completely confused me too. I think "surrogateopt" uses a MOSEK solver to solve mixed-integer programming. However, I cannot understand the origin of this error.
In R2022b, line 138 of linprog contains
error(message('optim:linprog:NotEnoughInputs'))
which is an error message, but it is the message
LINPROG requires at least three input arguments.
I would suggest putting in a breakpoint at line 138 of linprog and try to figure out whether maybe the function message has been overridden
Unfortunately you did not happen to include enough code and data for us to be able to test on our systems.
Thank you for your time. I checked "liprog" function but I couldn't understand why this error arise. As I know, "linprog" just is used to generate a feasible point for initialization. I have attached the simplified/minimal code to this comment. I think it can be run in your system. I hope you can find the origin of this error.
clc
clear
close all
format compact
rng('default') % For reproducibility
%% Initialization
W_Total = 20e6;
R_Cov = 1000;
M = 20;
B = 4;
K = 10;
sigma2_dB = 0;
sigma2 = 10^(sigma2_dB/10);
phi_u = unifrnd(0, 2*pi, 1, M);
alpha_u = unifrnd(0.01*R_Cov, 0.9*R_Cov, 1, M);
Xu = alpha_u.*[cos(phi_u) ; sin(phi_u) ; zeros(1,M)];
%% Initialization for Optimization
P_DL_b_m = rand(B,M);
P_DL_b = rand(1,B);
h_b_m = rand(B,M);
%%% Mixed-Integer "Surrogate" Optimization
Objconstr = @(phi) DL_Sum_Throughput_test (phi, P_DL_b_m, h_b_m, sigma2, K, W_Total); % Objective Function
%%% Equality Constraints
A_Eq1 = kron( ones(1,B) , eye(M) ); % Dim: M x BM
A_Eq2 = kron( ones(1,K) , eye(M) ); % Dim: M x KM
b_Eq1 = ones(M,1); % Dim: M x 1
b_Eq2 = ones(M,1); % Dim: M x 1
A_Eq = [A_Eq1 , zeros(M,K*(M+1));
zeros(M,B*M) , A_Eq2 , zeros(M,K)]; % Dim: 2M x M(B+K)+K
b_Eq = [b_Eq1 ; b_Eq2]; % Dim: 2M x 1
%%% Inequality Constraints
A_InEq1 = kron( eye(B) , ones(1,M) ); % Dim: B x BM
b_InEq1 = round(P_DL_b'./sum(P_DL_b) *M); % Dim: B x 1
A_InEq2 = ones(1,K);
b_InEq2 = W_Total;
A_InEq = [A_InEq1 , zeros(B,K*(M+1)) ;
zeros(1,M*(B+K)) , A_InEq2] ; % Dim: B+1 x M(B+K)+K
b_InEq = [b_InEq1 ; b_InEq2]; % Dim: B+1 x 1
intcon = 1:1:M*(B+K); % Indice of DVs that are integer-value
lb = zeros(M*(B+K)+K , 1); % Lower bounds of DVs
ub = [ones(M*(B+K) , 1) ; ones(K,1)*W_Total]; % Upper bounds of DVs
options_surr = optimoptions('surrogateopt', ...
'PlotFcn','surrogateoptplot', ...
'ConstraintTolerance',1e-2,...
'MaxFunctionEvaluations',100);
problem_surr = struct('objective',Objconstr,'lb',lb,'ub',ub,'intcon',intcon,...
'Aineq',A_InEq,'bineq',b_InEq,'Aeq',A_Eq,'beq',b_Eq,'options',options_surr,'solver','surrogateopt');
[x_surr, fval_surr, exitflag_surr, output_surr, trials_surr] = surrogateopt(problem_surr);
The linear constraints and bounds are infeasible.
On our system the code complains about the bounds being infeasible, not about the number of input arguments.
It might be because the "Mosek" solver not being installed on your system.
You do not call the Mosek solver in your code.
If the Mosek solver is interfering, then the problem is something in the Mosek solver, such as if the solver provides its own linprog() that is being called instead of MATLAB's.
Experiment with
restoredefaultpath; rehash toolboxcache
and see if the code starts working (or at least not giving the mosek error.) If it does then use tests such as
which -all linprog
or use the debugger to figure out where a non-mathworks function is being called.
your solution is a shit!!!!! I run the command, and every intalled toolbox fails, I need to add all their path one by one! such an idiot

Sign in to comment.

Answers (0)

Products

Release

R2022b

Commented:

on 26 Sep 2025

Community Treasure Hunt

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

Start Hunting!