-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_FullFactorial.cpp
More file actions
50 lines (38 loc) · 1.44 KB
/
test_FullFactorial.cpp
File metadata and controls
50 lines (38 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include "optipp.h"
using namespace std;
using namespace AnalysisGenerator;
int main()
{
shared_ptr<AnalysisParametersBlock> block= AnalysisParametersBlock::create();
block->addParameter("x", vector<double>{0, .11, .33, .44, .77, .99, 1});
block->addParameter("y", -1, 1);
block->addParameter("z", 0, 10);
block->addObjective("o1", AnalysisObjective::MIN_);
block->addObjective("o2", AnalysisObjective::MAX_);
block->addConstraint("c1", -1, 1);
block->addConstraint("c2", AnalysisConstraint::LB_,1);
function<bool(shared_ptr<AnalysisParametersBlock>&, int)> objf = [](shared_ptr<AnalysisParametersBlock>& tempBlock, int index)->bool
{
auto x= tempBlock->getValue("x", index);
auto y= tempBlock->getValue("y", index);
auto z= tempBlock->getValue("z", index);
tempBlock->setObjective("o1", x + y, index);
tempBlock->setObjective("o2", z - y, index);
tempBlock->setConstraint("c1", x + y, index);
tempBlock->setConstraint("c2", z - y, index);
return true;
};
shared_ptr<Generator> FF_Generator(new FullFactorial(block));
FF_Generator->setOption("x", "5");
FF_Generator->setOption("y", "5");
FF_Generator->setOption("z", "5");
Model model(FF_Generator);
//model.setBlock(block);
model.setObjf(objf);
model.run();
model.dumpSamples(R"(C:\tmp\samples_FF.txt)", 0);// , OPTIPP_DUMP_FEAS | OPTIPP_DUMP_PARETO);
block->evalCorrCoeff();
return 0;
}