At least n variables not zero

View: New views
3 Messages — Rating Filter:   Alert me  

At least n variables not zero

by annaf02 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear All,

Is it possible to ask lpsolve to find a solution of a problem with say m variables such that at least n (<m) of them are not zero?
I had a look at the special ordered sets but it seems to be something like the opposite of the restriction I am looking for.

Any help is very much appreciated.
Anna


Re: At least n variables not zero

by Peter Notebaert-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You will have to use binary variables for that.

For each variable in your model you will have to add an extra binary variable, add constraints to make it 0 if your variable is 0 and 1 if non-zero and then add an extra contraint that the sum of the added binary vars is >= n

Peter

--- In lp_solve@..., "annaf02" <annaf02@...> wrote:
>
> Dear All,
>
> Is it possible to ask lpsolve to find a solution of a problem with say m variables such that at least n (<m) of them are not zero?
> I had a look at the special ordered sets but it seems to be something like the opposite of the restriction I am looking for.
>
> Any help is very much appreciated.
> Anna
>



Re: At least n variables not zero

by annaf02 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

Thank you ever so much!

Anna

--- In lp_solve@..., "peter_notebaert" <_peno_@...> wrote:

>
> You will have to use binary variables for that.
>
> For each variable in your model you will have to add an extra binary variable, add constraints to make it 0 if your variable is 0 and 1 if non-zero and then add an extra contraint that the sum of the added binary vars is >= n
>
> Peter
>
> --- In lp_solve@..., "annaf02" <annaf02@> wrote:
> >
> > Dear All,
> >
> > Is it possible to ask lpsolve to find a solution of a problem with say m variables such that at least n (<m) of them are not zero?
> > I had a look at the special ordered sets but it seems to be something like the opposite of the restriction I am looking for.
> >
> > Any help is very much appreciated.
> > Anna
> >
>