Borrar filtros
Borrar filtros

Nonlinear constraint function error

1 visualización (últimos 30 días)
Maddie Sanders
Maddie Sanders el 19 de Sept. de 2022
Respondida: Akshat Dalal el 4 de Oct. de 2023
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 comentarios
Maddie Sanders
Maddie Sanders el 19 de Sept. de 2022
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 el 19 de Sept. de 2022
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.

Iniciar sesión para comentar.

Respuestas (1)

Akshat Dalal
Akshat Dalal el 4 de Oct. de 2023
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

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by