本文整理汇总了C++中OsiClpSolverInterface::loadProblem方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::loadProblem方法的具体用法?C++ OsiClpSolverInterface::loadProblem怎么用?C++ OsiClpSolverInterface::loadProblem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::loadProblem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModelScenario
void ModelScenario(const char * const name )
{
OsiClpSolverInterface *osiClp1 = new OsiClpSolverInterface();
double INF=osiClp1->getInfinity();
// example of direct interfaces for scenario generation
/* Model dimensions */
int nels=44; // ncol=27, nrow=9
/* Sparse matrix data...organized by row */
int mrow[]={ 0, 0, 0, 0, 0,
1, 1, 1, 1,
2, 2, 2,
3, 3, 3, 3, 3,
4, 4, 4, 4,
5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8 };
int mcol[]={ 0, 1, 2, 3, 4,
5, 6, 7, 8,
9,10, 11,
12, 13, 14, 15, 16,
0, 12, 17, 18,
1, 5, 9, 13, 19, 20,
2, 6, 14, 21, 22,
3, 7, 10, 15, 23, 24,
4, 8, 11, 16, 25, 26 };
double dels[] = { 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0,
16.0, 9.0, -1.0, 1.0,
15.0, 10.0, 5.0, 11.0, -1.0, 1.0,
28.0, 14.0, 22.0, -1.0, 1.0,
23.0, 15.0, 7.0, 17.0, -1.0, 1.0,
81.0, 57.0, 29.0, 55.0, -1.0, 1.0 };
/* Objective */
double dobj[]={ 18.0, 21.0, 18.0, 16.0, 10.0, 15.0, 16.0, 14.0, 9.0,
10.0, 9.0, 6.0, 17.0, 16.0, 17.0, 15.0, 10.0, 0.0,
13.0, 0.0, 13.0, 0.0, 7.0, 0.0, 7.0, 0.0, 1.0 };
/* Column bounds */
double dclo[]={ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double dcup[]={ INF, INF, INF, INF, INF, INF, INF, INF, INF,
INF, INF, INF, INF, INF, INF, INF, INF, INF,
INF, INF, INF, INF, INF, INF, INF, INF, INF };
/* Row bounds */
double drlo[]={ -INF, -INF, -INF, -INF, 0.0, 4.0, 0.0, 8.0, 10.0 };
double drup[]={ 10.0, 19.0, 25.0, 15.0, 0.0, 7.0, 0.0, 8.0, 90.0 };
/* Stages */
int nstg=2;
int n_first_stg_rows=4;
int rstg[]={ 0,0,0,0,1,1,1,1,1 };
int cstg[]={ 0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1 };
/* Stochastic data */
int nindp=5;
int nsamp[]={ 5, 2, 5, 5, 3 };
double demand[]={ 200, 220, 250, 270, 300,
50, 150,
140, 160, 180, 200, 220,
10, 50, 80, 100, 340,
580, 600, 620 };
double dprobs[]={ 0.2, 0.05, 0.35, 0.2, 0.2,
0.3, 0.7,
0.1, 0.2, 0.4, 0.2, 0.1,
0.2, 0.2, 0.3, 0.2, 0.1,
0.1, 0.8, 0.1 };
/* local variables */
int ns=1,ii,iii,jj,*indx,*incr;
double dp=1.0;
for (ii=0;ii<nindp;ii++) ns *= nsamp[ii]; /* Compute number of scenarios */
// initialize SmiModel
SmiScnModel *smiModel = new SmiScnModel();
smiModel->setOsiSolverHandle(*osiClp1);
// set core model using Osi interface
OsiClpSolverInterface ocsi;
ocsi.loadProblem(CoinPackedMatrix( 1,mrow,mcol,dels,nels),dclo,dcup,dobj,drlo,drup);
SmiCoreData *osiCore = new SmiCoreData(&ocsi,nstg,cstg,rstg);
cout << "ModelScenario: Created CoreData" << endl;
//.........这里部分代码省略.........
示例2: ModelDiscrete
void ModelDiscrete(const char * const name)
{
// example of direct interfaces for discrete distribution
OsiClpSolverInterface *osiClp1 = new OsiClpSolverInterface();
double INF=osiClp1->getInfinity();
/* Model dimensions */
int nels=44; // ncol=27, nrow=9
/* Sparse matrix data...organized by row */
int mrow[]={ 0, 0, 0, 0, 0,
1, 1, 1, 1,
2, 2, 2,
3, 3, 3, 3, 3,
4, 4, 4, 4,
5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8 };
int mcol[]={ 0, 1, 2, 3, 4,
5, 6, 7, 8,
9,10, 11,
12, 13, 14, 15, 16,
0, 12, 17, 18,
1, 5, 9, 13, 19, 20,
2, 6, 14, 21, 22,
3, 7, 10, 15, 23, 24,
4, 8, 11, 16, 25, 26 };
double dels[] = { 1.0, 1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, 1.0, 1.0, 1.0,
16.0, 9.0, -1.0, 1.0,
15.0, 10.0, 5.0, 11.0, -1.0, 1.0,
28.0, 14.0, 22.0, -1.0, 1.0,
23.0, 15.0, 7.0, 17.0, -1.0, 1.0,
81.0, 57.0, 29.0, 55.0, -1.0, 1.0 };
/* Objective */
/* Objective */
double dobj[]={ 18.0, 21.0, 18.0, 16.0, 10.0, 15.0, 16.0, 14.0, 9.0,
10.0, 9.0, 6.0, 17.0, 16.0, 17.0, 15.0, 10.0, 0.0,
13.0, 0.0, 13.0, 0.0, 7.0, 0.0, 7.0, 0.0, 1.0 };
/* Column bounds */
double dclo[]={ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double dcup[]={ INF, INF, INF, INF, INF, INF, INF, INF, INF,
INF, INF, INF, INF, INF, INF, INF, INF, INF,
INF, INF, INF, INF, INF, INF, INF, INF, INF };
/* Row bounds */
double drlo[]={ -INF, -INF, -INF, -INF, 0.0, 4.0, 0.0, 8.0, 10.0 };
double drup[]={ 10.0, 19.0, 25.0, 15.0, 0.0, 7.0, 0.0, 8.0, 90.0 };
/* Stages */
int nstg=2;
int n_first_stg_rows=4;
int rstg[]={ 0,0,0,0,1,1,1,1,1 };
int cstg[]={ 0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1 };
/* Stochastic data */
int nindp=5;
int nsamp[]={ 5, 2, 5, 5, 3 };
double demand[]={ 200, 220, 250, 270, 300,
50, 150,
140, 160, 180, 200, 220,
10, 50, 80, 100, 340,
580, 600, 620 };
double dprobs[]={ 0.2, 0.05, 0.35, 0.2, 0.2,
0.3, 0.7,
0.1, 0.2, 0.4, 0.2, 0.1,
0.2, 0.2, 0.3, 0.2, 0.1,
0.1, 0.8, 0.1 };
/* local variables */
int ii,jj;
// initialize SmiModel
SmiScnModel *smiModel = new SmiScnModel();
smiModel->setOsiSolverHandle(*osiClp1);
// set core model using Osi interface
OsiClpSolverInterface ocsi;
ocsi.loadProblem(CoinPackedMatrix( 1,mrow,mcol,dels,nels),dclo,dcup,dobj,drlo,drup);
// core model
SmiCoreData *smiCore = new SmiCoreData(&ocsi,nstg,cstg,rstg);
cout << "ModelDiscrete: generated Core data" << endl;
//.........这里部分代码省略.........