📄 hartmut_documentation
字号:
orig_lower_bounds
basis
lower
must_be_int
update Basis info
set bounds for slack variables
change_sign for rhs, but comparison is made with sense of constraint.
rows_end_valid = false
put slackvariable for this row into basis
if lp == active, set globals
eta_file = non_valid.
void str_add_constraint(lprec *lp,
char *row_string,
short constr_type,
REAL rh)
This routine is similar to the routine str_set_obj_fn. The same idea,
but call add_constraint.
void del_constraint(lprec *lp, int del_row)
First check, if rownumber exists.
For all columns
For every coefficient in column
if it is not rownumber,
then shift elements to smaller nonzero index and perhaps correct row index.
else delete
update col_end
shift values for orig_rhs, ch_sign, bas, row_name down by one.
Update values in bas
shift values for lower, basis, orig_upbo, orig_lowbo, must_be_int, scaling down
by one.
update rows and sum
set row_end_valid = FALSE
if lp = active, set globals.
eta_valid = FALSE
basis_valid = FALSE
void add_lag_con(lprec *lp, REAL *row, short con_type, REAL rhs)
Calloc/Realloc space for lag_row, lag_rhs, lambda, lag_con_type
Fill arrays.
void str_add_lag_con(lprec *lp, char *row, short con_type, REAL rhs)
Same idea as always. Reserve space for array, strtod values into this array,
call add_lag_con and free array.
void add_column(lprec *lp, REAL *column)
update columns and sums,
increment space for columns and matrix
if scaling used
set scaling factor for column to "1" and scale all values with row[scaling].
for all elements in (dense) column
if value is not zero
write it in matrix.
update col_end
orig_lowbo
orig_upbo
lower
basis
must_be_int
invent perhaps name for column
row_end_valid = FALSE
if lp = active
set sum, columns, non_zeros
void str_add_column(lprec *lp, char *col_string)
Same idea as always. Reserve space for array, strtod values into this array,
call add_column and free array.
void del_column(lprec *lp, int column)
check, if column is in range
if column in Basis set basis_valid to FALSE
else update bas
shift names_used,
must_be_int
orig_upbo
orig_lowbo
upbo
lowbo
basis
lower
scaling
update lagrangean stuff
copy elements in matrix down.
update col_end
update non_zeros
row_end_valid = FALSE
eta_valid = FALSE
update sum
column
if lp = active
set_globals()
void set_upbo(lprec *lp, int column, REAL value)
Test if column number in range
scale value
Test, if new value is feasible (greater than lower bound)
eta_valid = FALSE
set orig_upbo
void set_lowbo(lprec *lp, int column, REAL value)
Test if column number in range
scale value
Test, if new value is feasible (smaller than upper bound)
eta_valid = FALSE
set orig_lowbo
void set_int(lprec *lp, int column, short must_be_int)
Test if column number in range
set must_be_int
If variable must be integer, unscale column
void set_rh(lprec *lp, int row, REAL value)
Test, if row_number is in range
Test, if row_number for objective row should be set, WARNING
scale value and change sign.
eta_valid = FALSE
void set_rh_vec(lprec *lp, REAL *rh)
For all rows
scale and change sign
set orig_rh
eta_valid = FALSE
void str_set_rh_vec(lprec *lp, char *rh_string)
Same idea as always. Reserve space for array, strtod values into this array,
call set_rh_vec and free array.
void set_maxim(lprec *lp)
if maxim == FALSE
multiply all Values in row[0] with -1
eta_valid = FALSE
set maximise = TRUE
ch_sign[0] = TRUE
if LP = active, set Maximise = TRUE
void set_minim(lprec *lp)
if maxim == TRUE
multiply all Values in row[0] with -1
eta_valid = FALSE
set maximise = FALSE
ch_sign[0] = FALSE
if LP = active, set Maximise = FALSE
void set_constr_type(lprec *lp, int row, short con_type)
Test, if row_number is in range
if type == EQUAL
set upper bound on slackvariable to zero
basis_valid == FALSE
if change_sign[row]
multiply all coefficients with -1
eta_valid = FALSE
change_sign = FALSE
change sign of orig_rh
if type == LESSEQUAL
set upper bound on slackvariable to infinity
basis_valid == FALSE
if change_sign[row]
multiply all coefficients with -1
eta_valid = FALSE
change_sign = FALSE
change sign of orig_rh
if type == GREATEREQUAL
set upper bound on slackvariable to infinity
basis_valid == FALSE
if NOT change_sign[row]
multiply all coefficients with -1
eta_valid = FALSE
change_sign = TRUE
change sign of orig_rh
else
error wrong constraint type
REAL mat_elm(lprec *lp, int row, int column)
/* get value of matrix element in row and column */
Test, if row_number is in range
Test, if col_number is in range
value = 0
loop through column
if value found
unscale and change_sign
return value
void get_row(lprec *lp, int row_nr, REAL *row)
/* this is dense form */
Test, if row_number is in range
for all columns
initialise value with 0
for all entries in column
if row found, write value
unscale value
if change_sign
multiply with -1
void get_column(lprec *lp, int col_nr, REAL *column)
Test, if column is in range.
/* column is dense*/
initialise columnarray with 0
for all elements in this colum, copy to dense array
unscale and change sign
void get_reduced_costs(lprec *lp, REAL *rc)
Basis has to be valid
set_globals
if eta_valid = FALSE
invert
initialise array with 0
set rc[0] = 1
btran(rc)
For all columns
if variable not in basis AND upper bound > 0
rc[column] = SUM (over all elements in Column) mat.value * rc[row]
round all values
short is_feasible(lprec *lp, REAL *values)
Unscale values and look, if they are between orig_lower and orig_upper bounds
allocate space for a new rhs
With this values calculate rhs
check if rhs is lessequal than orig rhs for LE rows and equal to orig_rhs
for EQ rows.
short column_in_lp(lprec *lp, REAL *testcolumn)
for all columns
for all elements in column
unscale value and change_sign
check if difference smaller than epsilon
return TRUE or FALSE
void print_lp(lprec *lp)
print rowwise in readable form.
void set_row_name(lprec *lp, int row, nstring new_name)
Perhaps allocate memory for names and initialise with default names
strcpy rowname
void set_col_name(lprec *lp, int column, nstring new_name)
Perhaps allocate memory for names and initialise with default names
strcpy colname
static REAL minmax_to_scale(REAL min, REAL max)
calculate scaling factor depending on min and max
void unscale_columns(lprec *lp)
for all columns
for all coefficients in column
unscale (columnscaling)
for all columns
unscale bounds
set scaling vector to 1
columns_scaled = FALSE
eta_valid = FALSE
void unscale(lprec *lp)
Work only if scaling used
for all columns
for all coefficients in column
unscale (columnscaling)
for all columns
unscale bounds
for all columns
for all coefficients in column
unscale (rowscaling)
for all rows
unscale orig_rhs
free scale
scaling_used = FALSE
eta_valid = FALSE
void auto_scale(lprec *lp)
find row maximum and row minimum. Use these values to scale problem.
void reset_basis(lprec *lp)
basis_valid=FALSE
void print_solution(lprec *lp)
Print solution to stdout
Print all variables
In some cases
Print slack variables ???
Print duals
void write_LP(lprec *lp, FILE *output)
print LP rowwise in readable form.
void write_MPS(lprec *lp, FILE *output)
The routine write_MPS seems to do no unscaling. However it uses internally
the routine get_column() which does unscaling!
void print_duals(lprec *lp)
Print all duals
void print_scales(lprec *lp)
Print all row scales
print all column scales.
/***************************************************************/
/** **/
/** **/
/** Routines in file "read.c" **/
/** **/
/** **/
/***************************************************************/
void yyerror(char *string)
void check_decl(char *str)
static int hashval(const char *string)
static hashelem *gethash(char *variable)
void add_int_var(char *name)
void init_read(void)
static column *getrow(column *p,
int row)
static bound *create_bound_rec(void)
void null_tmp_store(void)
static void store(char *variable,
int row,
REAL value)
void store_re_op(void)
void rhs_store(REAL value)
void var_store(char *var, int row, REAL value)
void store_bounds(void)
void add_constraint_name(char *name, int row)
void readinput(lprec *lp)
lprec *read_lp_file(FILE *input, short verbose, nstring lp_name)
===================================================
To understand the idea of this file you should also read carefully the
comments directly at the beginning of this file!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -