How to use add_SOS API

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

How to use add_SOS API

by t-nakata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear All.

I, add_SOS API attempted to use the definition of Special Orderd Sets.
Went well and the code below.(C#)

int hLP=lpsolve55.make_lp(0,6);
...
lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);

SOS has been generated such.

sos
SOS: C1,C2,C3,C4,C5,C6 <= 2:1;

And if the following code,

lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);

SOS was not generated.
But using the IDE, and 2 to 5 has been rewritten to get the solution.
I really want to SOS below.

SOS: C1,C2,C3,C4,C5,C6 <= 5;

Can I generate this SOS ,using API?
Please if you prefer your professor.


toshiya.nakata


Re: How to use add_SOS API

by peter_notebaert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you checked the return code of add_SOS? As specified in the API, 0 means that an error occured.
This will probably the case for your model. For SOS type bigger than 2, it is required that all your variables in the provided set are integer. Otherwise, lp_solve cannot handle this type of SOS.

Most solvers only support SOS1 and SOS2. lp_solve extended this to SOS3+, but it can only handle that if all variables in the SOS set are integer.
There was even a time that SOS3+ was completeley disabled because of a problem with that.

Peter


From: t-nakata
Sent: Sunday, November 08, 2009 11:21
To: lp_solve@...
Subject: [lp_solve] How to use add_SOS API


 
Dear All.

I, add_SOS API attempted to use the definition of Special Orderd Sets.
Went well and the code below.(C#)

int hLP=lpsolve55.make_lp(0,6);
...
lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);

SOS has been generated such.

sos
SOS: C1,C2,C3,C4,C5,C6 <= 2:1;

And if the following code,

lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);

SOS was not generated.
But using the IDE, and 2 to 5 has been rewritten to get the solution.
I really want to SOS below.

SOS: C1,C2,C3,C4,C5,C6 <= 5;

Can I generate this SOS ,using API?
Please if you prefer your professor.

toshiya.nakata




RE: How to use add_SOS API

by William H. Patton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I test the SOS4 example from the reference guide.

min: -x1 -x2 -3 x3 -2 x4 -2 x5;
c1: -x1 -x2 +x3 +x4 <= 30;
c2: +x1 +x3 -3 x4 <= 30;
x1 <= 40;
x2 <= 1;
x5 <= 1;
 
sos
SOS: x1,x2,x3,x4,x5 <= 4;

In the IDE I get the following warning in the console window.

add_SOS: SOS3+ members all have to be integer or semi-continuous.

Also I get a wrong solution: -235.75 with all variables not zero.

 

This is controlled  for lp_miplib.c line 547:

        /* If we have a high-order SOS (SOS3+) and this variable is
"intermediate"

          between members previously lower-bounded at a non-zero level, then
we should

          set this and similar neighbouring variables at non-zero
lowbo-values (remember

          that SOS3+ members are all either integers or semi-continuous).
Flag this

          situation and prune tree, since we cannot lower-bound. */

 

and messaged in lp_lib.c line 3757

  /* Make sure SOSes of order 3 and higher are properly defined */

  if(sostype > 2) {

    int j;

    for(k = 1; k <= count; k++) {

      j = sosvars[k];

      if(!is_int(lp, j) || !is_semicont(lp, j)) {

        report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
or semi-continuous.\n");

        return( 0 );

      }

    }

  }

The return of 0 signals that add SOS failed.

 

I suppose you coul try making the vars C1.C6 semi_continuous before calling
the add_SOS.

 

I think that the issue is the the "middle" vars C2..C5 must all be 0 or
strictly positive together.

So they need to be semi-continuous.

If there is no minimum set on a semi-continuous variable then the default
minimum is 1.

 

SO I try adding  to SOS4 example before the SOS section.

min: -x1 -x2 -3 x3 -2 x4 -2 x5;

c1: -x1 -x2 +x3 +x4 <= 30;

c2: +x1 +x3 -3 x4 <= 30;

x1 <= 40;

x2 <= 1;

x5 <= 1;

 

sec x1,x2,x3,x4,x5;

sos

SOS4: x1,x2,x3,x4,x5 <= 4;;

Nothing better happens,  The warning still happens about SOS3+ but the sec
is honored and a MIP branch and bound solve is done for the sec vars.

 

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

You can simulate SOS variables with binaries.

http://faculty.nps.edu/kwood/docs/AppelgetWood.pdf

 

Also, for your problem

SOS: C1,C2,C3,C4,C5,C6 <= 5;

If you also have the convexity row: sum Ci = 1 it becomes much simpler.

Then C1,C6 form an SOS1 ( one of them must be 0) and the convexity
constraint deals with C2..C5.

 

William

 

 

 

  _____  

From: lp_solve@... [mailto:lp_solve@...] On Behalf
Of t-nakata
Sent: Sunday, November 08, 2009 4:22 AM
To: lp_solve@...
Subject: [lp_solve] How to use add_SOS API

 

 

Dear All.

I, add_SOS API attempted to use the definition of Special Orderd Sets.
Went well and the code below.(C#)

int hLP=lpsolve55.make_lp(0,6);
...
lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);

SOS has been generated such.

sos
SOS: C1,C2,C3,C4,C5,C6 <= 2:1;

And if the following code,

lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);

SOS was not generated.
But using the IDE, and 2 to 5 has been rewritten to get the solution.
I really want to SOS below.

SOS: C1,C2,C3,C4,C5,C6 <= 5;

Can I generate this SOS ,using API?
Please if you prefer your professor.

toshiya.nakata




Re: How to use add_SOS API

by t-nakata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Peter.

Thanks for the answer immediately.
add_SOS to say I tried to check the return value.

int ret=lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);

And, ret=0. So SOS is why it is not generated.
Such a model has been generated and below.

/* Objective function */
min: +C1 +C2 +C3 +C4 +C5 +C6;

/* Constraints */
+C4 +C5 +2 C6 >= 3;
+C1 +2 C2 +3 C3 +C5 >= 3;
+3 C1 +C2 +2 C4 +C5 >= 3;

/* Integer definitions */
int C1,C2,C3,C4,C5,C6;

Then, IDE using the SOS has been added.

sos
SOS:C1,C2,C3,C4,C5,C6 <= 5;

Was similar to the following error message appears and.

add_SOS: SOS3+ members all have to be integer or semi-continuous.

That was impossible to define all the integer variables.
This is Why.

Please if you prefer your professor.

t-nakata

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

>
> Have you checked the return code of add_SOS? As specified in the API, 0 means that an error occured.
> This will probably the case for your model. For SOS type bigger than 2, it is required that all your variables in the provided set are integer. Otherwise, lp_solve cannot handle this type of SOS.
>
> Most solvers only support SOS1 and SOS2. lp_solve extended this to SOS3+, but it can only handle that if all variables in the SOS set are integer.
> There was even a time that SOS3+ was completeley disabled because of a problem with that.
>
> Peter
>
>
> From: t-nakata
> Sent: Sunday, November 08, 2009 11:21
> To: lp_solve@...
> Subject: [lp_solve] How to use add_SOS API
>
>
>  
> Dear All.
>
> I, add_SOS API attempted to use the definition of Special Orderd Sets.
> Went well and the code below.(C#)
>
> int hLP=lpsolve55.make_lp(0,6);
> ...
> lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);
>
> SOS has been generated such.
>
> sos
> SOS: C1,C2,C3,C4,C5,C6 <= 2:1;
>
> And if the following code,
>
> lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);
>
> SOS was not generated.
> But using the IDE, and 2 to 5 has been rewritten to get the solution.
> I really want to SOS below.
>
> SOS: C1,C2,C3,C4,C5,C6 <= 5;
>
> Can I generate this SOS ,using API?
> Please if you prefer your professor.
>
> toshiya.nakata
>



Re: How to use add_SOS API

by t-nakata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear William.

Thank you for your advice.

What to make of any errors found.
Source code, I try to read well.
And I try to read the paper too.

Thank you.

t-nakata

--- In lp_solve@..., "William H. Patton" <pattonwh@...> wrote:

>
> I test the SOS4 example from the reference guide.
>
> min: -x1 -x2 -3 x3 -2 x4 -2 x5;
> c1: -x1 -x2 +x3 +x4 <= 30;
> c2: +x1 +x3 -3 x4 <= 30;
> x1 <= 40;
> x2 <= 1;
> x5 <= 1;
>  
> sos
> SOS: x1,x2,x3,x4,x5 <= 4;
>
> In the IDE I get the following warning in the console window.
>
> add_SOS: SOS3+ members all have to be integer or semi-continuous.
>
> Also I get a wrong solution: -235.75 with all variables not zero.
>
>  
>
> This is controlled  for lp_miplib.c line 547:
>
>         /* If we have a high-order SOS (SOS3+) and this variable is
> "intermediate"
>
>           between members previously lower-bounded at a non-zero level, then
> we should
>
>           set this and similar neighbouring variables at non-zero
> lowbo-values (remember
>
>           that SOS3+ members are all either integers or semi-continuous).
> Flag this
>
>           situation and prune tree, since we cannot lower-bound. */
>
>  
>
> and messaged in lp_lib.c line 3757
>
>   /* Make sure SOSes of order 3 and higher are properly defined */
>
>   if(sostype > 2) {
>
>     int j;
>
>     for(k = 1; k <= count; k++) {
>
>       j = sosvars[k];
>
>       if(!is_int(lp, j) || !is_semicont(lp, j)) {
>
>         report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
> or semi-continuous.\n");
>
>         return( 0 );
>
>       }
>
>     }
>
>   }
>
> The return of 0 signals that add SOS failed.
>
>  
>
> I suppose you coul try making the vars C1.C6 semi_continuous before calling
> the add_SOS.
>
>  
>
> I think that the issue is the the "middle" vars C2..C5 must all be 0 or
> strictly positive together.
>
> So they need to be semi-continuous.
>
> If there is no minimum set on a semi-continuous variable then the default
> minimum is 1.
>
>  
>
> SO I try adding  to SOS4 example before the SOS section.
>
> min: -x1 -x2 -3 x3 -2 x4 -2 x5;
>
> c1: -x1 -x2 +x3 +x4 <= 30;
>
> c2: +x1 +x3 -3 x4 <= 30;
>
> x1 <= 40;
>
> x2 <= 1;
>
> x5 <= 1;
>
>  
>
> sec x1,x2,x3,x4,x5;
>
> sos
>
> SOS4: x1,x2,x3,x4,x5 <= 4;;
>
> Nothing better happens,  The warning still happens about SOS3+ but the sec
> is honored and a MIP branch and bound solve is done for the sec vars.
>
>  
>
> Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>  
>
> You can simulate SOS variables with binaries.
>
> http://faculty.nps.edu/kwood/docs/AppelgetWood.pdf
>
>  
>
> Also, for your problem
>
> SOS: C1,C2,C3,C4,C5,C6 <= 5;
>
> If you also have the convexity row: sum Ci = 1 it becomes much simpler.
>
> Then C1,C6 form an SOS1 ( one of them must be 0) and the convexity
> constraint deals with C2..C5.
>
>  
>
> William
>
>  
>
>  
>
>  
>
>   _____  
>
> From: lp_solve@... [mailto:lp_solve@...] On Behalf
> Of t-nakata
> Sent: Sunday, November 08, 2009 4:22 AM
> To: lp_solve@...
> Subject: [lp_solve] How to use add_SOS API
>
>  
>
>  
>
> Dear All.
>
> I, add_SOS API attempted to use the definition of Special Orderd Sets.
> Went well and the code below.(C#)
>
> int hLP=lpsolve55.make_lp(0,6);
> ...
> lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);
>
> SOS has been generated such.
>
> sos
> SOS: C1,C2,C3,C4,C5,C6 <= 2:1;
>
> And if the following code,
>
> lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);
>
> SOS was not generated.
> But using the IDE, and 2 to 5 has been rewritten to get the solution.
> I really want to SOS below.
>
> SOS: C1,C2,C3,C4,C5,C6 <= 5;
>
> Can I generate this SOS ,using API?
> Please if you prefer your professor.
>
> toshiya.nakata
>



RE: Re: How to use add_SOS API

by William H. Patton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is revised code for lp_lib.c that tests sos3+ correctly.

int __WINAPI add_SOS(lprec *lp, char *name, int sostype, int priority, int
count, int *sosvars, REAL *weights)

{

  SOSrec *SOS;

  int    k;

 

  if((sostype < 1) || (count < 0)) {

    report(lp, IMPORTANT, "add_SOS: Invalid SOS type definition %d\n",
sostype);

    return( 0 );

  }

 

  /* Make sure SOSes of order 3 and higher are properly defined */

  if(sostype > 2) {

    int j;

    for(k = 0; k < count; k++) { // zero based in caller

      j = sosvars[k];

      if(!(is_int(lp, j) || is_semicont(lp, j)) ) {

        report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
or semi-continuous.\n");

        return( 0 );

      }

    }

  }

 

  /* Make size in the list to handle another SOS record */

 

//Also a test file

min: -x1 -x2 -3 x3 -2 x4 -2 x5;

c1: -x1 -x2 +x3 +x4 <= 30;

c2: +x1 +x3 -3 x4 <= 30;

x1 <= 40;

x2 <= 1.1;

x5 <= 1.1;

 

sec x1,x2,x3,x4,x5;

//int  x1,x2,x3,x4,x5;

sos

SOS4: x1,x2,x3,x4,x5 <= 4;

 

It might also work if the test for sos3+ is just ignored.

The MPS reader does not call this test and the MPS examples in the reference
guide work anyway without

the integer or semi continuous restriction.

 

It should be clear that there have been no uses of SOS3+ since version
5.5.0.3 because this code has not changed.

The release Readme indicates that even for sos1 and sos2 there have been
many troubles with presolve.

So I recommend keeping presolve off with SOS.

The general literature indicates that there MAY be Branch and Bound
implementation difficulties with

Overlapping SOS sets.  That is any time a variable occurs in two or more
different SOS sets.

I think lp_solve may manage these cases anyway. But it also may not.

 

As Peter points out, almost no other solver makes SOS sets of type greater
than 2 available.

So a test of an important BEST solution will be hard to check.

 

From a branch management point of view nothing is different about SOS1 and
SOSn.

In each case a branch var is selected as the highest index in the adjacent
set of allowed non-zeros, then the variables outside these adjacent
variables are fixed at 0 and the branch evaluated.  Even for overlapping SOS
cases, the only care necessary should be that an attempt to set a var which
is already fixed at non-zero to 0 should produce an immediate infeasible for
the branch.

 

Good luck and send a working example when you get one please.

 

William

  _____  

From: lp_solve@... [mailto:lp_solve@...] On Behalf
Of t-nakata
Sent: Sunday, November 08, 2009 8:14 PM
To: lp_solve@...
Subject: [lp_solve] Re: How to use add_SOS API

 

 


Dear William.

Thank you for your advice.

What to make of any errors found.
Source code, I try to read well.
And I try to read the paper too.

Thank you.

Here is revised cod

--- In lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com,
"William H. Patton" <pattonwh@...> wrote:

>
> I test the SOS4 example from the reference guide.
>
> min: -x1 -x2 -3 x3 -2 x4 -2 x5;
> c1: -x1 -x2 +x3 +x4 <= 30;
> c2: +x1 +x3 -3 x4 <= 30;
> x1 <= 40;
> x2 <= 1;
> x5 <= 1;
>
> sos
> SOS: x1,x2,x3,x4,x5 <= 4;
>
> In the IDE I get the following warning in the console window.
>
> add_SOS: SOS3+ members all have to be integer or semi-continuous.
>
> Also I get a wrong solution: -235.75 with all variables not zero.
>
>
>
> This is controlled for lp_miplib.c line 547:
>
> /* If we have a high-order SOS (SOS3+) and this variable is
> "intermediate"
>
> between members previously lower-bounded at a non-zero level, then
> we should
>
> set this and similar neighbouring variables at non-zero
> lowbo-values (remember
>
> that SOS3+ members are all either integers or semi-continuous).
> Flag this
>
> situation and prune tree, since we cannot lower-bound. */
>
>
>
> and messaged in lp_lib.c line 3757
>
> /* Make sure SOSes of order 3 and higher are properly defined */
>
> if(sostype > 2) {
>
> int j;
>
> for(k = 1; k <= count; k++) {
>
> j = sosvars[k];
>
> if(!is_int(lp, j) || !is_semicont(lp, j)) {
>
> report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
> or semi-continuous.\n");
>
> return( 0 );
>
> }
>
> }
>
> }
>
> The return of 0 signals that add SOS failed.
>
>
>
> I suppose you coul try making the vars C1.C6 semi_continuous before
calling

> the add_SOS.
>
>
>
> I think that the issue is the the "middle" vars C2..C5 must all be 0 or
> strictly positive together.
>
> So they need to be semi-continuous.
>
> If there is no minimum set on a semi-continuous variable then the default
> minimum is 1.
>
>
>
> SO I try adding to SOS4 example before the SOS section.
>
> min: -x1 -x2 -3 x3 -2 x4 -2 x5;
>
> c1: -x1 -x2 +x3 +x4 <= 30;
>
> c2: +x1 +x3 -3 x4 <= 30;
>
> x1 <= 40;
>
> x2 <= 1;
>
> x5 <= 1;
>
>
>
> sec x1,x2,x3,x4,x5;
>
> sos
>
> SOS4: x1,x2,x3,x4,x5 <= 4;;
>
> Nothing better happens, The warning still happens about SOS3+ but the sec
> is honored and a MIP branch and bound solve is done for the sec vars.
>
>
>
> Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
>
> You can simulate SOS variables with binaries.
>
> http://faculty. <http://faculty.nps.edu/kwood/docs/AppelgetWood.pdf>
nps.edu/kwood/docs/AppelgetWood.pdf

>
>
>
> Also, for your problem
>
> SOS: C1,C2,C3,C4,C5,C6 <= 5;
>
> If you also have the convexity row: sum Ci = 1 it becomes much simpler.
>
> Then C1,C6 form an SOS1 ( one of them must be 0) and the convexity
> constraint deals with C2..C5.
>
>
>
> William
>
>
>
>
>
>
>
> _____
>
> From: lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com
[mailto:lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com] On
Behalf

> Of t-nakata
> Sent: Sunday, November 08, 2009 4:22 AM
> To: lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com
> Subject: [lp_solve] How to use add_SOS API
>
>
>
>
>
> Dear All.
>
> I, add_SOS API attempted to use the definition of Special Orderd Sets.
> Went well and the code below.(C#)
>
> int hLP=lpsolve55.make_lp(0,6);
> ...
> lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);
>
> SOS has been generated such.
>
> sos
> SOS: C1,C2,C3,C4,C5,C6 <= 2:1;
>
> And if the following code,
>
> lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);
>
> SOS was not generated.
> But using the IDE, and 2 to 5 has been rewritten to get the solution.
> I really want to SOS below.
>
> SOS: C1,C2,C3,C4,C5,C6 <= 5;
>
> Can I generate this SOS ,using API?
> Please if you prefer your professor.
>
> toshiya.nakata
>




Re: How to use add_SOS API

by t-nakata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear William.

SOS often proved very difficult to implement.
Not available or to reduce the number of cutting patterns I wanted to...
But give up.And decided to consider another approach.

Thank you.

t-nakata

--- In lp_solve@..., "William H. Patton" <pattonwh@...> wrote:

>
> Here is revised code for lp_lib.c that tests sos3+ correctly.
>
> int __WINAPI add_SOS(lprec *lp, char *name, int sostype, int priority, int
> count, int *sosvars, REAL *weights)
>
> {
>
>   SOSrec *SOS;
>
>   int    k;
>
>  
>
>   if((sostype < 1) || (count < 0)) {
>
>     report(lp, IMPORTANT, "add_SOS: Invalid SOS type definition %d\n",
> sostype);
>
>     return( 0 );
>
>   }
>
>  
>
>   /* Make sure SOSes of order 3 and higher are properly defined */
>
>   if(sostype > 2) {
>
>     int j;
>
>     for(k = 0; k < count; k++) { // zero based in caller
>
>       j = sosvars[k];
>
>       if(!(is_int(lp, j) || is_semicont(lp, j)) ) {
>
>         report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
> or semi-continuous.\n");
>
>         return( 0 );
>
>       }
>
>     }
>
>   }
>
>  
>
>   /* Make size in the list to handle another SOS record */
>
>  
>
> //Also a test file
>
> min: -x1 -x2 -3 x3 -2 x4 -2 x5;
>
> c1: -x1 -x2 +x3 +x4 <= 30;
>
> c2: +x1 +x3 -3 x4 <= 30;
>
> x1 <= 40;
>
> x2 <= 1.1;
>
> x5 <= 1.1;
>
>  
>
> sec x1,x2,x3,x4,x5;
>
> //int  x1,x2,x3,x4,x5;
>
> sos
>
> SOS4: x1,x2,x3,x4,x5 <= 4;
>
>  
>
> It might also work if the test for sos3+ is just ignored.
>
> The MPS reader does not call this test and the MPS examples in the reference
> guide work anyway without
>
> the integer or semi continuous restriction.
>
>  
>
> It should be clear that there have been no uses of SOS3+ since version
> 5.5.0.3 because this code has not changed.
>
> The release Readme indicates that even for sos1 and sos2 there have been
> many troubles with presolve.
>
> So I recommend keeping presolve off with SOS.
>
> The general literature indicates that there MAY be Branch and Bound
> implementation difficulties with
>
> Overlapping SOS sets.  That is any time a variable occurs in two or more
> different SOS sets.
>
> I think lp_solve may manage these cases anyway. But it also may not.
>
>  
>
> As Peter points out, almost no other solver makes SOS sets of type greater
> than 2 available.
>
> So a test of an important BEST solution will be hard to check.
>
>  
>
> From a branch management point of view nothing is different about SOS1 and
> SOSn.
>
> In each case a branch var is selected as the highest index in the adjacent
> set of allowed non-zeros, then the variables outside these adjacent
> variables are fixed at 0 and the branch evaluated.  Even for overlapping SOS
> cases, the only care necessary should be that an attempt to set a var which
> is already fixed at non-zero to 0 should produce an immediate infeasible for
> the branch.
>
>  
>
> Good luck and send a working example when you get one please.
>
>  
>
> William
>
>   _____  
>
> From: lp_solve@... [mailto:lp_solve@...] On Behalf
> Of t-nakata
> Sent: Sunday, November 08, 2009 8:14 PM
> To: lp_solve@...
> Subject: [lp_solve] Re: How to use add_SOS API
>
>  
>
>  
>
>
> Dear William.
>
> Thank you for your advice.
>
> What to make of any errors found.
> Source code, I try to read well.
> And I try to read the paper too.
>
> Thank you.
>
> Here is revised cod
>
> --- In lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com,
> "William H. Patton" <pattonwh@> wrote:
> >
> > I test the SOS4 example from the reference guide.
> >
> > min: -x1 -x2 -3 x3 -2 x4 -2 x5;
> > c1: -x1 -x2 +x3 +x4 <= 30;
> > c2: +x1 +x3 -3 x4 <= 30;
> > x1 <= 40;
> > x2 <= 1;
> > x5 <= 1;
> >
> > sos
> > SOS: x1,x2,x3,x4,x5 <= 4;
> >
> > In the IDE I get the following warning in the console window.
> >
> > add_SOS: SOS3+ members all have to be integer or semi-continuous.
> >
> > Also I get a wrong solution: -235.75 with all variables not zero.
> >
> >
> >
> > This is controlled for lp_miplib.c line 547:
> >
> > /* If we have a high-order SOS (SOS3+) and this variable is
> > "intermediate"
> >
> > between members previously lower-bounded at a non-zero level, then
> > we should
> >
> > set this and similar neighbouring variables at non-zero
> > lowbo-values (remember
> >
> > that SOS3+ members are all either integers or semi-continuous).
> > Flag this
> >
> > situation and prune tree, since we cannot lower-bound. */
> >
> >
> >
> > and messaged in lp_lib.c line 3757
> >
> > /* Make sure SOSes of order 3 and higher are properly defined */
> >
> > if(sostype > 2) {
> >
> > int j;
> >
> > for(k = 1; k <= count; k++) {
> >
> > j = sosvars[k];
> >
> > if(!is_int(lp, j) || !is_semicont(lp, j)) {
> >
> > report(lp, IMPORTANT, "add_SOS: SOS3+ members all have to be integer
> > or semi-continuous.\n");
> >
> > return( 0 );
> >
> > }
> >
> > }
> >
> > }
> >
> > The return of 0 signals that add SOS failed.
> >
> >
> >
> > I suppose you coul try making the vars C1.C6 semi_continuous before
> calling
> > the add_SOS.
> >
> >
> >
> > I think that the issue is the the "middle" vars C2..C5 must all be 0 or
> > strictly positive together.
> >
> > So they need to be semi-continuous.
> >
> > If there is no minimum set on a semi-continuous variable then the default
> > minimum is 1.
> >
> >
> >
> > SO I try adding to SOS4 example before the SOS section.
> >
> > min: -x1 -x2 -3 x3 -2 x4 -2 x5;
> >
> > c1: -x1 -x2 +x3 +x4 <= 30;
> >
> > c2: +x1 +x3 -3 x4 <= 30;
> >
> > x1 <= 40;
> >
> > x2 <= 1;
> >
> > x5 <= 1;
> >
> >
> >
> > sec x1,x2,x3,x4,x5;
> >
> > sos
> >
> > SOS4: x1,x2,x3,x4,x5 <= 4;;
> >
> > Nothing better happens, The warning still happens about SOS3+ but the sec
> > is honored and a MIP branch and bound solve is done for the sec vars.
> >
> >
> >
> > Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >
> >
> >
> > You can simulate SOS variables with binaries.
> >
> > http://faculty. <http://faculty.nps.edu/kwood/docs/AppelgetWood.pdf>
> nps.edu/kwood/docs/AppelgetWood.pdf
> >
> >
> >
> > Also, for your problem
> >
> > SOS: C1,C2,C3,C4,C5,C6 <= 5;
> >
> > If you also have the convexity row: sum Ci = 1 it becomes much simpler.
> >
> > Then C1,C6 form an SOS1 ( one of them must be 0) and the convexity
> > constraint deals with C2..C5.
> >
> >
> >
> > William
> >
> >
> >
> >
> >
> >
> >
> > _____
> >
> > From: lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com
> [mailto:lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com] On
> Behalf
> > Of t-nakata
> > Sent: Sunday, November 08, 2009 4:22 AM
> > To: lp_solve@yahoogroup <mailto:lp_solve%40yahoogroups.com> s.com
> > Subject: [lp_solve] How to use add_SOS API
> >
> >
> >
> >
> >
> > Dear All.
> >
> > I, add_SOS API attempted to use the definition of Special Orderd Sets.
> > Went well and the code below.(C#)
> >
> > int hLP=lpsolve55.make_lp(0,6);
> > ...
> > lpsolve55.add_SOS(hLP , "SOS" , 2 , 1 , 6 , arr , null);
> >
> > SOS has been generated such.
> >
> > sos
> > SOS: C1,C2,C3,C4,C5,C6 <= 2:1;
> >
> > And if the following code,
> >
> > lpsolve55.add_SOS(hLP , "SOS" , 5 , 1 , 6 , arr , null);
> >
> > SOS was not generated.
> > But using the IDE, and 2 to 5 has been rewritten to get the solution.
> > I really want to SOS below.
> >
> > SOS: C1,C2,C3,C4,C5,C6 <= 5;
> >
> > Can I generate this SOS ,using API?
> > Please if you prefer your professor.
> >
> > toshiya.nakata
> >
>



RE: Re: How to use add_SOS API

by William H. Patton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A very good document on SOS can be found in

http://sourceforge.net/projects/lpsolve/files/lpsolve/4.0.1.11/lp_solve_4.0.
tar.gz/download

file        SOSInterpolation.pdf

It does SOS2 via binaries. Page 17:         2.7 SOS2 variables modeled using
binary variables

But the method extends to SOSn by replacing the  sum of 2 deltas in (8) with
sum of n deltas.

 

This document is hard to find on the net any longer. But thanks for Erwin at


            http://yetanothermathprogrammingconsultant.blogspot.com/

for creating it in 2002.

 

William

 

  _____  

From: lp_solve@... [mailto:lp_solve@...] On Behalf
Of t-nakata
Sent: Tuesday, November 10, 2009 1:52 AM
To: lp_solve@...
Subject: [lp_solve] Re: How to use add_SOS API

 

 


Dear William.

SOS often proved very difficult to implement.
Not available or to reduce the number of cutting patterns I wanted to...
But give up.And decided to consider another approach.

Thank you.

t-nakata







Re: How to use add_SOS API

by t-nakata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear William

Thanks for the valuable information.
I'm excited.

In order to understand more, to purchase translation software!

Thank you very mutch.

t-nakata

--- In lp_solve@..., "William H. Patton" <pattonwh@...> wrote:

>
> A very good document on SOS can be found in
>
> http://sourceforge.net/projects/lpsolve/files/lpsolve/4.0.1.11/lp_solve_4.0.
> tar.gz/download
>
> file        SOSInterpolation.pdf
>
> It does SOS2 via binaries. Page 17:         2.7 SOS2 variables modeled using
> binary variables
>
> But the method extends to SOSn by replacing the  sum of 2 deltas in (8) with
> sum of n deltas.
>
>  
>
> This document is hard to find on the net any longer. But thanks for Erwin at
>
>
>             http://yetanothermathprogrammingconsultant.blogspot.com/
>
> for creating it in 2002.
>
>  
>
> William
>
>  
>
>   _____  
>
> From: lp_solve@... [mailto:lp_solve@...] On Behalf
> Of t-nakata
> Sent: Tuesday, November 10, 2009 1:52 AM
> To: lp_solve@...
> Subject: [lp_solve] Re: How to use add_SOS API
>
>  
>
>  
>
>
> Dear William.
>
> SOS often proved very difficult to implement.
> Not available or to reduce the number of cutting patterns I wanted to...
> But give up.And decided to consider another approach.
>
> Thank you.
>
> t-nakata
>