⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glpk02.tex

📁 著名的大规模线性规划求解器源码GLPK.C语言版本,可以修剪.内有详细帮助文档.
💻 TEX
📖 第 1 页 / 共 5 页
字号:
\subsubsection*{Description}The routine \verb|glp_set_row_bnds| sets (changes) the type and boundsof \verb|i|-th row (auxiliary variable) of the specified problem object.The parameters \verb|type|, \verb|lb|, and \verb|ub| specify the type,lower bound, and upper bound, respectively, as follows:\begin{center}\begin{tabular}{cr@{}c@{}ll}Type & \multicolumn{3}{c}{Bounds} & Comment \\\hline\verb|GLP_FR| & $-\infty <$ &$\ x\ $& $< +\infty$   & Free (unbounded) variable \\\verb|GLP_LO| & $lb \leq$ &$\ x\ $& $< +\infty$   & Variable with lower bound \\\verb|GLP_UP| & $-\infty <$ &$\ x\ $& $\leq ub$   & Variable with upper bound \\\verb|GLP_DB| & $lb \leq$ &$\ x\ $& $\leq ub$   & Double-bounded variable \\\verb|GLP_FX| & $lb =$ &$\ x\ $& $= ub$   & Fixed variable \\\end{tabular}\end{center}\noindentwhere $x$ is the auxiliary variable associated with $i$-th row.If the row has no lower bound, the parameter \verb|lb| is ignored. Ifthe row has no upper bound, the parameter \verb|ub| is ignored. If therow is an equality constraint (i.e. the corresponding auxiliary variableis of fixed type), only the parameter \verb|lb| is used while theparameter \verb|ub| is ignored.Being added to the problem object each row is initially free, i.e. itstype is \verb|GLP_FR|.\newpage\subsection{glp\_set\_col\_bnds---set (change) column bounds}\subsubsection*{Synopsis}\begin{verbatim}void glp_set_col_bnds(glp_prob *lp, int j, int type,      double lb, double ub);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_set_col_bnds| sets (changes) the type and boundsof \verb|j|-th column (structural variable) of the specified problemobject.The parameters \verb|type|, \verb|lb|, and \verb|ub| specify the type,lower bound, and upper bound, respectively, as follows:\begin{center}\begin{tabular}{cr@{}c@{}ll}Type & \multicolumn{3}{c}{Bounds} & Comment \\\hline\verb|GLP_FR| & $-\infty <$ &$\ x\ $& $< +\infty$   & Free (unbounded) variable \\\verb|GLP_LO| & $lb \leq$ &$\ x\ $& $< +\infty$   & Variable with lower bound \\\verb|GLP_UP| & $-\infty <$ &$\ x\ $& $\leq ub$   & Variable with upper bound \\\verb|GLP_DB| & $lb \leq$ &$\ x\ $& $\leq ub$   & Double-bounded variable \\\verb|GLP_FX| & $lb =$ &$\ x\ $& $= ub$   & Fixed variable \\\end{tabular}\end{center}\noindentwhere $x$ is the structural variable associated with $j$-th column.If the column has no lower bound, the parameter \verb|lb| is ignored.If the column has no upper bound, the parameter \verb|ub| is ignored.If the column is of fixed type, only the parameter \verb|lb| is usedwhile the parameter \verb|ub| is ignored.Being added to the problem object each column is initially fixed atzero, i.e. its type is \verb|GLP_FX| and both bounds are 0.\subsection{glp\_set\_obj\_coef---set (change) objective coefficientor constant term}\subsubsection*{Synopsis}\begin{verbatim}void glp_set_obj_coef(glp_prob *lp, int j, double coef);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_set_obj_coef| sets (changes) the objectivecoefficient at \verb|j|-th column (structural variable). A new value ofthe objective coefficient is specified by the parameter \verb|coef|.If the parameter \verb|j| is 0, the routine sets (changes) the constantterm (``shift'') of the objective function.\subsection{glp\_set\_mat\_row---set (replace) row of the constraintmatrix}\subsubsection*{Synopsis}\begin{verbatim}void glp_set_mat_row(glp_prob *lp, int i, int len,      const int ind[], const double val[]);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_set_mat_row| stores (replaces) the contents of\verb|i|-th row of the constraint matrix of the specified problemobject.Column indices and numerical values of new row elements must be placedin locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,\dots, \verb|val[len]|, respectively, where $0 \leq$ \verb|len| $\leq n$is the new length of $i$-th row, $n$ is the current number of columns inthe problem object. Elements with identical column indices are notallowed. Zero elements are allowed, but they are not stored in theconstraint matrix.If the parameter \verb|len| is 0, the parameters \verb|ind| and/or\verb|val| can be specified as \verb|NULL|.\subsection{glp\_set\_mat\_col---set (replace) column of theconstr\-aint matrix}\subsubsection*{Synopsis}\begin{verbatim}void glp_set_mat_col(glp_prob *lp, int j, int len,      const int ind[], const double val[]);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_set_mat_col| stores (replaces) the contents of\verb|j|-th column of the constraint matrix of the specified problemobject.Row indices and numerical values of new column elements must be placedin locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,\dots, \verb|val[len]|, respectively, where $0 \leq$ \verb|len| $\leq m$is the new length of $j$-th column, $m$ is the current number of rows inthe problem object. Elements with identical row indices are not allowed.Zero elements are allowed, but they are not stored in the constraintmatrix.If the parameter \verb|len| is 0, the parameters \verb|ind| and/or\verb|val| can be specified as \verb|NULL|.\subsection{glp\_load\_matrix---load (replace) the whole constraintmatrix}\subsubsection*{Synopsis}\begin{verbatim}void glp_load_matrix(glp_prob *lp, int ne, const int ia[],      const int ja[], const double ar[]);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_load_matrix| loads the constraint matrix passedin  the arrays \verb|ia|, \verb|ja|, and \verb|ar| into the specifiedproblem object. Before loading the current contents of the constraintmatrix is destroyed.Constraint coefficients (elements of the constraint matrix) must bespecified as triplets (\verb|ia[k]|, \verb|ja[k]|, \verb|ar[k]|) for$k=1,\dots,ne$, where \verb|ia[k]| is the row index, \verb|ja[k]| isthe column index, and \verb|ar[k]| is a numeric value of correspondingconstraint coefficient. The parameter \verb|ne| specifies the totalnumber of (non-zero) elements in the matrix to be loaded. Coefficientswith identical indices are not allowed. Zero coefficients are allowed,however, they are not stored in the constraint matrix.If the parameter \verb|ne| is 0, the parameters \verb|ia|, \verb|ja|,and/or \verb|ar| can be specified as \verb|NULL|.\subsection{glp\_del\_rows---delete rows from problem object}\subsubsection*{Synopsis}\begin{verbatim}void glp_del_rows(glp_prob *lp, int nrs, const int num[]);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_del_rows| deletes rows from the specified problemob-\linebreak ject. Ordinal numbers of rows to be deleted should beplaced in locations \verb|num[1]|, \dots, \verb|num[nrs]|, where${\tt nrs}>0$.Note that deleting rows involves changing ordinal numbers of otherrows remaining in the problem object. New ordinal numbers of theremaining rows are assigned under the assumption that the originalorder of rows is not changed. Let, for example, before deletion therebe five rows $a$, $b$, $c$, $d$, $e$ with ordinal numbers 1, 2, 3, 4, 5,and let rows $b$ and $d$ have been deleted. Then after deletion theremaining rows $a$, $c$, $e$ are assigned new oridinal numbers 1, 2, 3.\subsection{glp\_del\_cols---delete columns from problem object}\subsubsection*{Synopsis}\begin{verbatim}void glp_del_cols(glp_prob *lp, int ncs, const int num[]);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_del_cols| deletes columns from the specifiedproblem object. Ordinal numbers of columns to be deleted should beplaced in locations \verb|num[1]|, \dots, \verb|num[ncs]|, where${\tt ncs}>0$.Note that deleting columns involves changing ordinal numbers of othercolumns remaining in the problem object. New ordinal numbers of theremaining columns are assigned under the assumption that the originalorder of columns is not changed. Let, for example, before deletion therebe six columns $p$, $q$, $r$, $s$, $t$, $u$ with ordinal numbers 1, 2,3, 4, 5, 6, and let columns $p$, $q$, $s$ have been deleted. Then afterdeletion the remaining columns $r$, $t$, $u$ are assigned new ordinalnumbers 1, 2, 3.\subsection{glp\_copy\_prob---copy problem object content}\subsubsection*{Synopsis}\begin{verbatim}void glp_copy_prob(glp_prob *dest, glp_prob *prob, int names);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_copy_prob| copies the content of the problemobject \verb|prob| to the problem object \verb|dest|.The parameter \verb|names| is a flag. If it is \verb|GLP_ON|,the routine also copies all symbolic names; otherwise, if it is\verb|GLP_OFF|, no symbolic names are copied.\subsection{glp\_erase\_prob---erase problem object content}\subsubsection*{Synopsis}\begin{verbatim}void glp_erase_prob(glp_prob *lp);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_erase_prob| erases the content of the specifiedproblem object. The effect of this operation is the same as if theproblem object would be deleted with the routine \verb|glp_delete_prob|and then created anew with the routine \verb|glp_create_prob|, with theonly exception that the handle (pointer) to the problem object remainsvalid.\subsection{glp\_delete\_prob---delete problem object}\subsubsection*{Synopsis}\begin{verbatim}void glp_delete_prob(glp_prob *lp);\end{verbatim}\subsubsection*{Description}The routine \verb|glp_delete_prob| deletes a problem object, which theparameter \verb|lp| points to, freeing all the memory allocated to thisobject.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\newpage\section{Problem retrieving routines}\subsection{glp\_get\_prob\_name---retrieve problem name}\subsubsection*{Synopsis}\begin{verbatim}const char *glp_get_prob_name(glp_prob *lp);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_prob_name| returns a pointer to an internalbuffer, which contains symbolic name of the problem. However, if theproblem has no assigned name, the routine returns \verb|NULL|.\subsection{glp\_get\_obj\_name---retrieve objective function name}\subsubsection*{Synopsis}\begin{verbatim}const char *glp_get_obj_name(glp_prob *lp);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_obj_name| returns a pointer to an internalbuffer, which contains symbolic name assigned to the objectivefunction. However, if the objective function has no assigned name, theroutine returns \verb|NULL|.\subsection{glp\_get\_obj\_dir---retrieve optimization direction flag}\subsubsection*{Synopsis}\begin{verbatim}int glp_get_obj_dir(glp_prob *lp);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_obj_dir| returns the optimization directionflag (i.e. ``sense'' of the objective function):\begin{tabular}{@{}ll}\verb|GLP_MIN| & minimization; \\\verb|GLP_MAX| & maximization. \\\end{tabular}\pagebreak\subsection{glp\_get\_num\_rows---retrieve number of rows}\subsubsection*{Synopsis}\begin{verbatim}int glp_get_num_rows(glp_prob *lp);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_num_rows| returns the current number of rowsin the specified problem object.\subsection{glp\_get\_num\_cols---retrieve number of columns}\subsubsection*{Synopsis}\begin{verbatim}int glp_get_num_cols(glp_prob *lp);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_num_cols| returns the current number ofcolumns the specified problem object.\subsection{glp\_get\_row\_name---retrieve row name}\subsubsection*{Synopsis}\begin{verbatim}const char *glp_get_row_name(glp_prob *lp, int i);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_row_name| returns a pointer to an internalbuffer, which contains a symbolic name assigned to \verb|i|-th row.However, if the row has no assigned name, the routine returns\verb|NULL|.\subsection{glp\_get\_col\_name---retrieve column name}\subsubsection*{Synopsis}\begin{verbatim}const char *glp_get_col_name(glp_prob *lp, int j);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_col_name| returns a pointer to an internalbuffer, which contains a symbolic name assigned to \verb|j|-th column.However, if the column has no assigned name, the routine returns\verb|NULL|.\subsection{glp\_get\_row\_type---retrieve row type}\subsubsection*{Synopsis}\begin{verbatim}int glp_get_row_type(glp_prob *lp, int i);\end{verbatim}\subsubsection*{Returns}The routine \verb|glp_get_row_type| returns the type of \verb|i|-th

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -