Hello, I didn't try this before, but I would start by doing something like the following.
First, let's say that your discrete optimization variable is called x1. Then, for each tried variable by the optimizer, I would add the following equality constraint rem(x1_trial,1) = 0 % this is matlab code So, in this code, I simply check the remainder and constraint it to zero which means that x1_trial should be always an integer. Of course, I would avoid derivative based optimizers and I would go for a derivative-free optimizer, e.g. COBYLA. All the best, Mohamed On Fri, May 13, 2016 at 9:27 AM, Bernard Van Antwerpen < [email protected]> wrote: > Dear all, > > > > We are using NLopt within Python since one year now, and are pretty happy > with it. > > We were just wondering how we would be able to force one design variable > to be discrete? > > > > Typically, we would need to be able to active/de-activate some components > in our analysis for instance. We’re doing this by setting the design > variable within the objective or inequality constraint function to an > integer to perform the computation. But this obviously pretty upsets the > optimizer as finding the gradients becomes complicated. Is there a way to > force some design variables to be discrete instead, while keeping other > ones as real values? > > > > Thanks for your help, > > > > Bernard > > _______________________________________________ > NLopt-discuss mailing list > [email protected] > http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss > >
_______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
