Error: "Not enough input arguments"

17 ビュー (過去 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 Center および File ExchangeDistillation Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by