Error using "mskoptimset"
Show older comments
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
Alan Weiss
on 28 Feb 2023
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
MohammadReza Jabbari (Jabari)
on 28 Feb 2023
Walter Roberson
on 28 Feb 2023
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.
MohammadReza Jabbari (Jabari)
on 3 Mar 2023
Edited: MohammadReza Jabbari (Jabari)
on 3 Mar 2023
Walter Roberson
on 3 Mar 2023
On our system the code complains about the bounds being infeasible, not about the number of input arguments.
MohammadReza Jabbari (Jabari)
on 3 Mar 2023
Edited: MohammadReza Jabbari (Jabari)
on 3 Mar 2023
Walter Roberson
on 3 Mar 2023
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.
C Euler
on 26 Sep 2025
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
Answers (0)
Categories
Find more on Surrogate Optimization 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!