4 Downloads
Updated 14 Jan 2000
No License
fminconset: Solves constrained minimization problems where some
of the variables are restricted to discrete values. (Mixed Integer
Nonlinear optimization). Based on fmincon from Optimization Toolbox
version 2.0.
Ingar Solberg (2021). fminconset (https://www.mathworks.com/matlabcentral/fileexchange/96-fminconset), MATLAB Central File Exchange. Retrieved .
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
I looking in the code and I believe following line provides explanation to my question:
if ~any(abs(x(i) - set{i}) < optimget(options,'TolX'))
=> by setting TolX, you set the maximum possible interval between the value of your set (like [0 1] for a binary variable) and the calculated value for the variable.
Therefore, unless you set TolX to 0, I guess you could always get some non-integer values for your variable.
Thanks Ingar for posting this piece!
However I have got some unconsistency in the results provided by the function for my problem:
It seems to work well in first approach (exitflat=2) and I get a "good" comment in the command window: Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
But when I look at the values for my variable, I see that I obtained non-integer values!!
I set:
set={[0 1],[0 1]};
x0=[0 0]'; xlb=[0 0]'; xub=[1 1]';
options=optimset('Hessian','off','largescale','off','Gradobj','off','Gradconstr','off','TolX',1e-6,'display','iter','tolcon',1e-6,'Derivativecheck','on','FinDiffRelStep',1e-10);
[x,h,exitflag,output,lambda,grad,hessian] = fminconset(fun,x0,[],[],[],[],xlb,xub,'nonlcon',options,set,Inf);
Do you have any idea what could be going wrong in the script? (I know it has been a while that you posted it!!)
I ran your example and it works well...
you could compare it with translation of the routine to Python, see http://openopt.org/MINLP for details.
I have not been able to download so far then send comments
matlab code for the diet problem