File Exchange

## fminconset

version 1.0.0.0 (11.7 KB) by
Solves constrained minimization problems, some of the variables are restricted to discrete values

Updated 14 Jan 2000

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.

### Cite As

Ingar Solberg (2021). fminconset (https://www.mathworks.com/matlabcentral/fileexchange/96-fminconset), MATLAB Central File Exchange. Retrieved .

Lenilein

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.

Lenilein

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]';

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...

Dmitrey Kroshko

you could compare it with translation of the routine to Python, see http://openopt.org/MINLP for details.

dinesh birla

moussa almou

matlab code for the diet problem

Girija Chetty

##### MATLAB Release Compatibility
Created with R11
Compatible with any release
##### Platform Compatibility
Windows macOS Linux