While performing multiobjective optimization, cplex status = -1. why? - multithreading

I have entered three objectives in my problem. The problem shown is as follows:
Description    Resource    Path    Location    Type
Exception from IBM ILOG CPLEX: 19118; 15 Unknown OPL Problem Marker CPLEX status = -1
Description    Resource    Path    Location    Type
IBM ILOG CPLEX Exception: MultipleObjException: IloCplex cannot handle multiple objectives. Unknown OPL Problem Marker 19118;15
My objective functions are;
minimize 0.5*(sum(i in tavail)0.5*((pt[i]-pl[i])));
maximize 0.25*(sum (i in tavail)(sum (j in number)(c[i]*pevdis[i][j])));
minimize 0.25* (sum (i in tavail)(sum (j in number)(c[i]*pevch[i][j])));

In a model you can have 0 or 1 (Maximize or Minimize)
But you can write
minimize 0.5*(sum(i in tavail)0.5*((pt[i]-pl[i])))
- 0.25*(sum (i in tavail)(sum (j in number)(c[i]*pevdis[i][j])))
+0.25* (sum (i in tavail)(sum (j in number)(c[i]*pevch[i][j])));
or if you want to rely on lexicographic multiobjective
minimize staticLex(0.5*(sum(i in tavail)0.5*((pt[i]-pl[i]))),
-0.25*(sum (i in tavail)(sum (j in number)(c[i]*pevdis[i][j])),
+0.25* (sum (i in tavail)(sum (j in number)(c[i]*pevch[i][j]))));
PS:
You ask many questions so let me share some entry points for learning more about cplex

Related

Math.Net Exponential Moving Average

I'm using simple moving average in Math.Net, but now that I also need to calculate EMA (exponential moving average) or any kind of weighted moving average, I don't find it in the library.
I looked over all methods under MathNet.Numerics.Statistics and beyond, but didn't find anything similar.
Is it missing in library or I need to reference some additional package?
I don't see any EMA in MathNet.Numerics, however it's trivial to program. The routine below is based on the definition at Investopedia.
public double[] EMA(double[] x, int N)
{
// x is the input series
// N is the notional age of the data used
// k is the smoothing constant
double k = 2.0 / (N + 1);
double[] y = new double[x.Length];
y[0] = x[0];
for (int i = 1; i < x.Length; i++) y[i] = k * x[i] + (1 - k) * y[i - 1];
return y;
}
Occasionally I found this package: https://daveskender.github.io/Stock.Indicators/docs/INDICATORS.html It targets to the latest .NET framework and has very detailed documents.
Try this:
public IEnumerable<double> EMA(IEnumerable<double> items, int notationalAge)
{
double k = 2.0d / (notationalAge + 1), prev = 0.0d;
var e = items.GetEnumerator();
if (!e.MoveNext()) yield break;
yield return prev = e.Current;
while(e.MoveNext())
{
yield return prev = (k * e.Current) + (1 - k) * prev;
}
}
It will still work with arrays, but also List, Queue, Stack, IReadOnlyCollection, etc.
Although it's not explicitly stated I also get the sense this is working with money, in which case it really ought to use decimal instead of double.

Open Scene Graph - Usage of DrawElementsUInt: Drawing a cloth without duplicating vertices

I am currently working on simulating a cloth like material and then displaying the results via Open Scene Graph.
I've gotten the setup to display something cloth like, by just dumping all the vertices into 1 Vec3Array and then displaying them with a standard Point based DrawArrays. However I am looking into adding the faces between the vertices so that a further part of my application can visually see the cloth.
This is currently what I am attempting as for the PrimitiveSet
// create and add a DrawArray Primitive (see include/osg/Primitive). The first
// parameter passed to the DrawArrays constructor is the Primitive::Mode which
// in this case is POINTS (which has the same value GL_POINTS), the second
// parameter is the index position into the vertex array of the first point
// to draw, and the third parameter is the number of points to draw.
unsigned int k = CLOTH_SIZE_X;
unsigned int n = CLOTH_SIZE_Y;
osg::ref_ptr<osg::DrawElementsUInt> indices = new osg::DrawElementsUInt(GL_QUADS, (k) * (n));
for (uint y_i = 0; y_i < n - 1; y_i++) {
for (uint x_i = 0; x_i < k - 1; x_i++) {
(*indices)[y_i * k + x_i] = y_i * k + x_i;
(*indices)[y_i * (k + 1) + x_i] = y_i * (k + 1) + x_i;
(*indices)[y_i * (k + 1) + x_i + 1] = y_i * (k + 1) + x_i + 1;
(*indices)[y_i * k + x_i] = y_i * k + x_i + 1;
}
}
geom->addPrimitiveSet(indices.get());
This does however cause memory corruption when running, and I am not fluent enough in Assembly code to decipher what it is trying to do wrong when CLion gives me the disassembled code.
My thought was that I would iterate over each of the faces of my cloth and then select the 4 indices of the vertices that belong to it. The vertices are inputted from top left to bottom right in order. So:
0 1 2 3 ... k-1
k k+1 k+2 k+3 ... 2k-1
2k 2k+1 2k+2 2k+3 ... 3k-1
...
Has anyone come across this specific use-case before and does he/she perhaps have a solution for my problem? Any help would be greatly appreciated.
You might want to look into using DrawArrays with QUAD_STRIP (or TRIANGLE_STRIP because quads are frowned upon these days). There's an example here:
http://openscenegraph.sourceforge.net/documentation/OpenSceneGraph/examples/osggeometry/osggeometry.cpp
It's slightly less efficient than Elements/indices, but it's also less complicated to manage the relationship between the two related containers (the vertices and the indices).
If you really want to do the Elements/indices route, we'd probably need to see more repro code to see what's going on.

Configure Iterative Closest Point PCL

I am having trouble configuring ICP in PCL 1.6(I use Android) and I believe that is the cause of an incorrect transformation matrix. What I've tried so far is this;
Downsample the point clouds I use in ICP with the following code:
pcl::VoxelGrid <pcl::PointXYZ> grid;
grid.setLeafSize(6, 6, 6);
grid.setInputCloud(output);
grid.filter(*tgt);
grid.setInputCloud(cloud_src);
grid.filter(*src);
Try to align the two point clouds with the following code :
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
icp.setInputCloud(tgt);
icp.setInputTarget(src);
pcl::PointCloud<pcl::PointXYZ> Final;
pcl::PointCloud<pcl::PointXYZ> transformedCloud;
icp.setMaxCorrespondenceDistance(0.08);
icp.setMaximumIterations(500);
//icp.setTransformationEpsilon (0.000000000000000000001);
icp.setTransformationEpsilon(1e-12);
icp.setEuclideanFitnessEpsilon(1e-12);
icp.setRANSACIterations(2000);
icp.setRANSACOutlierRejectionThreshold(0.6);
I have tried all kinds of values in the options of ICP but with no success.
The code I use to create the point cloud:
int density = 1;
for (int y = 0; y < depthFrame.getHeight(); y = y + density) {
for (int x = 0; x < depthFrame.getWidth(); x = x + density) {
short z = pDepthRow[y * depthVideoMode.getResolutionX() + x];
if (z > 0 && z < depthStream.getMaxPixelValue()) {
cloud_src->points[counter].x = x;
cloud_src->points[counter].y = y;
cloud_src->points[counter].z = z;
}
}
}
Any chance somebody can help me out configuring ICP?
From what I know, PCL uses meters as a unit of measurement. so, is it intended that leaf size for downsampling is 6*6*6 !? I think it's huge !!
Try with some lower values and if it didn't work either, try ICP with the most simple configuration as follows :
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
icp.setInputCloud(tgt);
icp.setInputTarget(src);
pcl::PointCloud<pcl::PointXYZ> Final;
icp.align(Final);
once, you got this working (and it should be), then start tuning the other parameters and it shouldn't be that hard to do.
Hope that helps, Cheers!

C# Parallel processing concept

I am working on image processing with C# and implementing integral histogram. I am not getting into the details, but assume that I have MxN matrix and each cell value is the sum of itself and its left and upper neighbor, minus left upper corner neighbor. This works fast but I want to make it faster for large images or for real time image processing performance.
matrix[i,j] += matrix[i-1,j] + matrix[i,j-1] - matrix[i-1,j-1];
The actual implementation is:
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
{
int left = 0, upper = 0, u_l_corner = 0;
if (j - 1 >= 0)
{
left = matrix[i, j - 1];
}
if (i - 1 >= 0)
{
upper = matrix[i - 1, j];
}
if (j - 1 >= 0 && i - 1 >= 0)
u_l_corner = matrix[i - 1, j - 1];
matrix[i, j] += left + upper - u_l_corner;
}
So the calculation is dependent on the previous values of cells. Therefore, it does not look like it can be implemented in parallel(at least to me). But still, just want to make sure before go any further..
Can this algorithm be implemented in parallel using Parallel.For or any other method in C#? If so a simple example is highly appreciated, but if not, I better work on to find a "parallel image histogram algorithm", if any exists.
Thanks in advance.
As far as I'm concerned it is possible to make this algorithm parallel but i find no use of doing so if your matrix is relatively small ( time to process is less than few miliseconds ).
If you are very interested in making this algorithm parallel you could make this task splitted to exactly "j" tasks ( number of items in "y" axis ).
Key to doing so is starting first thread to calculate points in first row of this matrice ( [i, 0] ) then starting second thread delayed - second thread should chase first thread - must never overtake preceding thread.

Video Synthesis - Making waves, patterns, gradients

I'm writing a program to generate some wild visuals. So far I can paint each pixel with a random blue value:
for (y = 0; y < YMAX; y++) {
for (x = 0; x < XMAX; x++) {
b = rand() % 255;
setPixelColor(x,y,r,g,b);
}
}
I'd like to do more than just make blue noise, but I'm not sure where to start (Google isn't helping me much today), so it would be great if you could share anything you know on the subject or some links to related resources.
I used to do such kind of tricks in the past. Unfortunately, I don't have the code :-/
You'll be amazed of what effects bitwise and integer arithmetic operators can produce:
FRAME_ITERATION++;
for (y = 0; y < YMAX; y++) {
for (x = 0; x < XMAX; x++) {
b = (x | y) % FRAME_ITERATION;
setPixelColor(x,y,r,g,b);
}
}
Sorry but I don't remember the exact combinations, so b = (x | y) % FRAME_ITERATION;
might actually render nothing beautiful. But, you can try your own combos.
Anyway, with code like the above, you can produce weird patterns and even water-like effects.
Waves are usually done with trig functions (sin/cos) or tables that approximate them.
You can also do some cool water ripples with some simple math. See here for code and an online demo.

Resources