You have NaNs in your constraints! Thanks for any answers!
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Limengtao
 el 9 de Abr. de 2020
  
    
    
    
    
    Comentada: Limengtao
 el 15 de Abr. de 2020
            %I have six order cycles, and various data for each order cycle,The purpose of the model is to meet the demand and minimize the total cost,This is all my code,% Is followed by related explanations
clc
cla
clf
clear all
close all
A= [...
40 30 2.1 2 3;
50 20 1.4 3 4;
60 20 1.3 4 5;
30 25 1.5 2 3;
35 35 1.2 2 5;
40 35 2.1 3 6;
    ];              %Data for six order cycles
D = A(:,1);         %Demand per cycle
C = A(:,2);             %Fixed costs incurred per order
P = A(:,3);             %Unit price for each order
H = A(:,4);             %Inventory costs per unit of unsold products
U = A(:,5);             %Product shortage cost per unit
t = size(A,1);             %Get the number of order cycles
X =  intvar(t,1,'full');             %Order quantity per cycle
Y =  binvar(t,1,'full');             %Whether to order at the tth cycle
S =  intvar(t,1,'full');             %Period-end inventory at period t
L =  intvar(t,1,'full');             %Shortage in period t
m=inf;
Z=0;
for i=1:t
                 Z = Z+(C(i)*Y(i)+P(i)*X(i)+H(i)*S(i)+U(i)*L(i));     %total cost
end
Constraint=[]; 
for i=1:t
                 Constraint = [Constraint, X(i)>=0,S(i)>=0,L(i)>=0];
end
Constraint = [Constraint,S(1)==X(1)-D(1)+L(1)];
for i=2:t
                   Constraint = [Constraint, S(i)==S(i-1)+X(i)-D(i)+L(i)]; %F=F+set(s(i)=s(i-1)+x(i)-d(i)+l(i));
end
for i=1:t
                 Constraint = [Constraint, X(i)<= m*Y(i),L(i)<=D(i)];% F=F+set(x(i)<=m*y(i));
end
Constraint = [Constraint,sum(Y)==3];
ops = sdpsettings('verbose',2,'solver','mosek'); 
sol = solvesdp(Constraint,Z,ops);
if sol.problem == 0
    value(X)
    value(Y)
    value(Z)
else
    disp('求解过程中出错');
end
%The error message is:
错误使用 compileinterfacedata (line 1061)
You have NaNs in your constraints!. Read more: https://yalmip.github.io/naninmodel/
出错 solvesdp (line 231)
[interfacedata,recoverdata,solver,diagnostic,F,~,ForiginalQuadratics] = compileinterfacedata(F,[],logdetStruct,h,options,0,solving_parametric);
出错 lotsize3 (line 54)
sol = solvesdp(Constraint,Z,ops);
%Thanks for any answers!
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 9 de Abr. de 2020
        Your last set of constraints includes
X(i)<= m*Y(i)
where m=inf and Y is binvar(). 
binvar() have a value of either 0 or 1. When the value is 0, then x(i)<=m*Y(i) would be x(i)<=inf*0 . However, inf*0 is NaN. Therefore if any Y(i) is ever 0 then the corresponding x(i) constraint would be NaN, which is not permitted.
Más respuestas (0)
Ver también
Categorías
				Más información sobre Surrogate Optimization en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

