Error: "Not enough input arguments"

2 vues (au cours des 30 derniers jours)
Eduardo Braga
Eduardo Braga le 6 Mar 2021
Commenté : Eduardo Braga le 6 Mar 2021
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 commentaires
Walter Roberson
Walter Roberson le 6 Mar 2021
Where is the error message being generated? What is the code you are using to run this code?
Eduardo Braga
Eduardo Braga le 6 Mar 2021

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Mar 2021
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 commentaire
Eduardo Braga
Eduardo Braga le 6 Mar 2021
I got it! thank you so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Distillation Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by