Error: "Not enough input arguments"

조회 수: 6 (최근 30일)
Eduardo Braga
Eduardo Braga 2021년 3월 6일
댓글: Eduardo Braga 2021년 3월 6일
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
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 3월 6일
Where is the error message being generated? What is the code you are using to run this code?
Eduardo Braga
Eduardo Braga 2021년 3월 6일

댓글을 달려면 로그인하십시오.

채택된 답변

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.
  댓글 수: 1
Eduardo Braga
Eduardo Braga 2021년 3월 6일
I got it! thank you so much!

댓글을 달려면 로그인하십시오.

추가 답변 (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