Error: "Not enough input arguments"

6 次查看(过去 30 天)
Hi. I'm new to matlab and I'm trying to optimize a distillation column with the NSGA II algorithm. However, I am having the following error: "Not enough input arguments". Can someone help me?
function [Obj, Cons] = Fun_Objective(X)
global Aspen
Stages = X(1) + 2;
Pressure = X(2);
Feed_Stage = round((Stages-4)*X(3) + 2);
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\NSTAGE").Value = Stages;
Aspen.Tree.FindNode("\Data\Blocks\B2\Subobjects\Column Internals\INT-1\Input\CA_STAGE2\INT-1\CS-1").Value = Stages - 1;
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\PRES1").Value = Pressure;
Aspen.Tree.FindNode("\Data\Blocks\B2\Input\FEED_STAGE\S50").Value = Feed_Stage;
Aspen.Reinit; % Reinit simulation
Aspen.Engine.Run2(1); %Run the simulation. (1) ---> Matlab isnt busy; (0) Matlab is Busy;
time = 1;
Error = 0;
while Aspen.Engine.IsRunning == 1 % 1 --> If Aspen is running; 0 ---> If Aspen stop.
pause(0.5);
time = time+1;
if time==600 % Control of simulation time.
Aspen.Engine.Stop;
Error = 1;
end
end
Conv = Aspen.Tree.FindNode("\Data\Results Summary\Run-Status\Output\PER_ERROR").Value; %Convergence Assessment
if Error == 0 && Conv == 0
Pur = Aspen.Tree.FindNode("\Data\Streams\S4\Output\MASSFLOW\MIXED\ACROL-01").Value/Aspen.Tree.FindNode("\Data\Streams\S4\Output\MASSFLMX\MIXED").Value;
Purity = 0.95 - Pur; %This means: Pur > 0.95 mol frac.
%Recovery > 0.98
Recovery = 0.98 - (Aspen.Tree.FindNode("\Data\Streams\S4\Output\MASSFLOW\MIXED\ACROL-01").Value/Aspen.Tree.FindNode("\Data\Streams\S50\Output\MASSFLOW\MIXED\ACROL-01").Value);
%Constraints Vector
c(1,1) = Purity;
c(1,2) = Recovery;
Cons = (c>0).*c; %Only accept unsatisfied constrainst: c > 0
CAPEX = AcrilonitrilaCAPEX()/10; %Fixed Distillation Cost
OPEX = AcrilonitrilaOPEX(); %Operating Distillation Cost
Obj = [CAPEX, OPEX]; %Objectives Function. CAPEX vs OPEX
else
Obj = [2e7, 2e7];
Cons = [1, 1];
end
end

采纳的回答

Walter Roberson
Walter Roberson 2021-3-6
You cannot run the objective function directly: you need to run a function such as the supplied Opt* function which sets up the conditions for everything to be called.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Distillation Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by