# set_var_weights

Set the weights on variables.

unsigned char set_var_weights(lprec *lp, REAL *weights);

Return Value

set_var_weights returns TRUE (1) if the operation was successful. A return value of FALSE (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

weights

The weights array.

Remarks

The set_var_weights sets a weight factor on each variable. This is only used for the integer variables in the branch-and-bound algorithm. Array members are unique, real-valued numbers indicating the "weight" of the variable at the given index. The array is 0-based. So variable 1 is at index 0, variable 2 at index 1. The array must contain get_Ncolumns elements.
The weights define which variable the branch-and-bound algorithm must select first. The lower the weight, the sooner the variable is chosen to make it integer.

Example

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

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

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

      weights[0] = 2;
      weights[1] = 1;

      set_var_weights(lp, 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, get_var_priority, set_var_branch, get_var_branch, set_bb_floorfirst, get_bb_floorfirst