필터 지우기
필터 지우기

Nonlinear constraint function error

조회 수: 1 (최근 30일)
Maddie Sanders
Maddie Sanders 2022년 9월 19일
답변: Akshat Dalal 2023년 10월 4일
Hello,
This is my first time using a genetic algorithm. I am having some issues.
This is the current error I am getting:
Error in microprocessor_ga_Sanders (line 10)
[best_X,best_Objective] =
ga(@microprocessor_cost,NVARS,[],[],[],[],lb,ub,@constraint_function_microprocessor,INTCON,options)
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation.
I will attach my codes and all my functions. Let me know if you have any questions.
The main code with the error is microprocessor_ga_Sanders.
  댓글 수: 5
Maddie Sanders
Maddie Sanders 2022년 9월 19일
What should be the result of doing this? I just tried doing it but am not able to get through all the code.
Maddie Sanders
Maddie Sanders 2022년 9월 19일
It seems like I am having an issue with my A_unfinned in my constraint function, but I have it in a different function and even when I defined it in the constraint function, I am still having issues.

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

답변 (1개)

Akshat Dalal
Akshat Dalal 2023년 10월 4일
Hi Maddie,
I understand you are facing an error while using a custom non-linear constraint function. I went through your code, and I believe the error is occurring because the variable ‘A_unfinned' is not declared in your custom constraint function.
I see that you have declared ‘A_unfinned’ in the ‘resistance_microprocessor’ function. However, this instance of ‘A_unfinned' cannot be used in your custom constraint function. This is because in MATLAB, each function is executed in its own personal ‘function workspace’ which is separate from the ‘base workspace’. The contents of a function’s workspace are local to that function and cannot be accessed by other functions. Thus, the variable ‘A_unfinned' declared in ‘resistance_microprocessor’ cannot be accessed in the Constraint function.
For more information on function workspace, you can refer to the following documentation - https://in.mathworks.com/help/matlab/matlab_prog/base-and-function-workspaces.html

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by