athos@1299
|
1 |
/* -*- C++ -*-
|
athos@1299
|
2 |
* src/lemon/lp_cplex.cc
|
athos@1299
|
3 |
* - Part of LEMON, a generic C++ optimization library
|
athos@1299
|
4 |
*
|
athos@1299
|
5 |
* Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
athos@1299
|
6 |
* (Egervary Combinatorial Optimization Research Group, EGRES).
|
athos@1299
|
7 |
*
|
athos@1299
|
8 |
* Permission to use, modify and distribute this software is granted
|
athos@1299
|
9 |
* provided that this copyright notice appears in all copies. For
|
athos@1299
|
10 |
* precise terms see the accompanying LICENSE file.
|
athos@1299
|
11 |
*
|
athos@1299
|
12 |
* This software is provided "AS IS" with no warranty of any kind,
|
athos@1299
|
13 |
* express or implied, and with no claim as to its suitability for any
|
athos@1299
|
14 |
* purpose.
|
athos@1299
|
15 |
*
|
athos@1299
|
16 |
*/
|
athos@1299
|
17 |
|
athos@1299
|
18 |
#include"lp_cplex.h"
|
athos@1299
|
19 |
|
athos@1299
|
20 |
///\file
|
athos@1299
|
21 |
///\brief Implementation of the LEMON-CPLEX lp solver interface.
|
athos@1299
|
22 |
namespace lemon {
|
athos@1299
|
23 |
|
athos@1299
|
24 |
int LpCplex::_addCol()
|
athos@1299
|
25 |
{
|
athos@1299
|
26 |
int i = CPXgetnumcols (env, lp);
|
athos@1299
|
27 |
int lb[1],ub[1];
|
athos@1299
|
28 |
lb[0]=-INF;//-CPX_INFBOUND;
|
athos@1299
|
29 |
ub[0]=INF;//CPX_INFBOUND;
|
athos@1299
|
30 |
status = CPXnewcols (env, lp, 1, NULL, lb, ub, NULL, NULL);
|
athos@1299
|
31 |
return i;
|
athos@1299
|
32 |
}
|
athos@1299
|
33 |
|
athos@1299
|
34 |
int LpCplex::_addRow()
|
athos@1299
|
35 |
{
|
athos@1299
|
36 |
int i = CPXgetnumrows (env, lp);
|
athos@1299
|
37 |
status = CPXnewrows (env, lp, 1, NULL, NULL, NULL, NULL, NULL);
|
athos@1299
|
38 |
return i;
|
athos@1299
|
39 |
}
|
athos@1299
|
40 |
|
athos@1299
|
41 |
///\warning Data at index 0 is ignored iin the arrays.
|
athos@1299
|
42 |
void LpCplex::_setRowCoeffs(int i,
|
athos@1299
|
43 |
int length,
|
athos@1299
|
44 |
int const * indices,
|
athos@1299
|
45 |
Value const * values )
|
athos@1299
|
46 |
{
|
athos@1299
|
47 |
int rowlist[length+1];
|
athos@1299
|
48 |
for (int k=1;k<=length;++k){
|
athos@1299
|
49 |
rowlist[k]=i;
|
athos@1299
|
50 |
}
|
athos@1299
|
51 |
status = CPXchgcoeflist(env, lp,
|
athos@1299
|
52 |
length,
|
athos@1299
|
53 |
rowlist++,
|
athos@1299
|
54 |
inices++,
|
athos@1299
|
55 |
values++);
|
athos@1299
|
56 |
}
|
athos@1299
|
57 |
|
athos@1299
|
58 |
void LpCplex::_setColCoeffs(int i,
|
athos@1299
|
59 |
int length,
|
athos@1299
|
60 |
int const * indices,
|
athos@1299
|
61 |
Value const * values)
|
athos@1299
|
62 |
{
|
athos@1299
|
63 |
int collist[length+1];
|
athos@1299
|
64 |
for (int k=1;k<=length;++k){
|
athos@1299
|
65 |
collist[k]=i;
|
athos@1299
|
66 |
}
|
athos@1299
|
67 |
status = CPXchgcoeflist(env, lp,
|
athos@1299
|
68 |
length,
|
athos@1299
|
69 |
inices++,
|
athos@1299
|
70 |
collist++,
|
athos@1299
|
71 |
values++);
|
athos@1299
|
72 |
}
|
athos@1299
|
73 |
|
athos@1299
|
74 |
void LpCplex::_setColLowerBound(int i, Value value)
|
athos@1299
|
75 |
{
|
athos@1299
|
76 |
}
|
athos@1299
|
77 |
|
athos@1299
|
78 |
void LpCplex::_setColUpperBound(int i, Value value)
|
athos@1299
|
79 |
{
|
athos@1299
|
80 |
}
|
athos@1299
|
81 |
|
athos@1299
|
82 |
void LpCplex::_setRowLowerBound(int i, Value value)
|
athos@1299
|
83 |
{
|
athos@1299
|
84 |
}
|
athos@1299
|
85 |
|
athos@1299
|
86 |
void LpCplex::_setRowUpperBound(int i, Value value)
|
athos@1299
|
87 |
{
|
athos@1299
|
88 |
}
|
athos@1299
|
89 |
|
athos@1299
|
90 |
void LpCplex::_setObjCoeff(int i, Value obj_coef)
|
athos@1299
|
91 |
{
|
athos@1299
|
92 |
}
|
athos@1299
|
93 |
|
athos@1299
|
94 |
LpCplex::SolutionType LpCplex::_solve()
|
athos@1299
|
95 |
{
|
athos@1299
|
96 |
return OPTIMAL;
|
athos@1299
|
97 |
}
|
athos@1299
|
98 |
|
athos@1299
|
99 |
LpCplex::Value LpCplex::_getSolution(int i)
|
athos@1299
|
100 |
{
|
athos@1299
|
101 |
return 0;
|
athos@1299
|
102 |
}
|
athos@1299
|
103 |
|
athos@1299
|
104 |
} //namespace lemon
|
athos@1299
|
105 |
|