필터 지우기
필터 지우기

alternative command to 'find'

조회 수: 1 (최근 30일)
Ditiro Setlhaolo
Ditiro Setlhaolo 2014년 4월 15일
댓글: Ditiro Setlhaolo 2014년 4월 16일
Hello, i am trying to declare this nonlinear constraint in opti toolbox using scip solver. I just want to ask if there is an alternative command for 'find'
nlcon3= @(x) [x(9*N+(find(x(9*N+1:10*N),1,'first')))* x(9*N+(find(x(9*N+1:10*N),1,'first'))+1)*x(9*N+(find(x(9*N+1:10*N),1,'first'))+2)*x(9*N+(find(x(9*N+1:10*N),1,'first'))+3)*x(9*N+(find(x(9*N+1:10*N),1,'first'))+4)];
nlrhs3 =1;
nle3 =1;
Thank you for your support.

채택된 답변

Walter Roberson
Walter Roberson 2014년 4월 15일
nlcon3= @(x) product(x((0:4) + x(9*N+(find(x(9*N+1:10*N),1,'first')));

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2014년 4월 15일
Instead of using an anonymous function, you could write that into its own function file and then only call find once, assign the output to a variable and use that variable a few times.
  댓글 수: 1
Ditiro Setlhaolo
Ditiro Setlhaolo 2014년 4월 16일
I have it as;
function y=nlcon(x)
y=prod(x((0:4) + x(9*N+(find(x(9*N+1:10*N),1,'first')))
end
but i still get the error "There was an error processing a constraint function into SCIP compatible form. Please examine the below error to correct your function: Undefined function 'find' for input arguments of type 'scipvar'. (Remember SCIP only supports a subset of MATLAB commands)"
Not sure about 'assign the output to a variable and use that variable a few times'.
Any further suggestions are humbly welcome. Ditiro

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


Ditiro Setlhaolo
Ditiro Setlhaolo 2014년 4월 15일
Thank you for your suggestions good people. I wanted to find out if there is an equivalent command to 'find' that is compatible with opti toolbox scip solver since 'find' is not.
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 4월 15일
I see no evidence that "find" is not compatible with opti toolbox. I do see evidence that it did not work the way you called it. It would have been easier on us if you had given us the same information you gave the OPTI forum in https://groups.google.com/forum/#!topic/opti-toolbox-forum/14YggFfG11s namely that you get an error
Undefined function 'find' for input arguments of type 'scipvar'.
and that
(Remember SCIP only supports a subset of MATLAB commands)
Rather than having us guess about what SCIP does support, you should post a link to that information.
Ditiro Setlhaolo
Ditiro Setlhaolo 2014년 4월 16일
Thank you Walter for that observation, and yes it was first posted at the opti forum https://groups.google.com/forum/#!topic/opti-toolbox-forum/14YggFfG11s. Havent had a breakthrough yet hence trying this forum. Thank you also for the suggestion above. Ditiro

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by