add_SOS

Add a SOS (Special Ordered Sets) constraint.

int add_SOS(lprec *lp, char *name, short 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.
lp->spx_status specifies what error occurred.

Parameters

lp

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

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.

Remarks

The add_SOS function adds an SOS constraint.

Example

#include <stdio.h>
#include <stdlib.h>
#include "lpkit.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", 3, 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_file, read_LP, read_mps, read_MPS, is_SOS_var