add_SOS

Add a SOS (Special Ordered Sets) constraint.

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

Return Value

add_SOS returns the list index of the new SOS if the operation was successful. A return value of 0 indicates an error.

Parameters

lp

Pointer to previously created lp model. See return value of make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI

name

The name of the SOS constraint.

sostype

The type of the SOS constraint. Must be >= 1

priority

Priority of the SOS constraint in the SOS set.

count

The number of variables in the SOS list.

sosvars

An array specifying the count variables (their column numbers).

weights

An array specifying the count variable weights. May also be NULL. In that case, lp_solve will weight the variables in the order they are specified.

Remarks

The add_SOS function adds an SOS constraint.
See Special Ordered Sets for a description about SOS variables.

Example

#include <stdio.h>
#include <stdlib.h>
#include "lp_lib.h"

int main(void)
{
  lprec *lp;
  int vars[2];
  double weights[2];

  /* Create a new LP model */
  lp = make_lp(0, 4);
  if(lp == NULL) {
    fprintf(stderr, "Unable to create new LP model\n");
    return(1);
  }

  vars[0] = 2; vars[1] = 3;
  weights[0] = 1.0; weights[1] = 2.0;
  add_SOS(lp, "SOS", 1, 1, sizeof(vars)/sizeof(*vars), vars, weights);

  delete_lp(lp);
  return(0);
}

lp_solve API reference

See Also make_lp, copy_lp, read_lp, read_LP, read_mps, read_freemps, read_MPS, read_freeMPS, read_XLI, is_SOS_var