Incremented optimization variables depending on data

Hi, I have a problem of minimizing a function to optimize variables which 2 of them are depending on number of data point. for example, and for each data point, the routine must generate two solutions , one for x[0] and one for x[1], and the rest of 6 variables generate 1 set only , and for two data points the program must generate 4 solutions 2 for x[0] and 2 for x[1], and 6 variables of one set , and so on .
I want to put bounds on x[0] and x[1] depending on number of data points . For example for 3 data points I make the following but it does not work and the purpose is to bound only x[0] and x[1] to data points and the rest of variables are constrained by other bounds:

enter code here
// for data point Number 1 to bound x[0]:
for (int i=0; i<=Ndata-2;i++){
for (int j=0; j<=Ndata-2;j++){

int ix0_= xx0_index(i,j);


x_l[ix0_] = lb_x01_;

x_u[ix0_] = ub_x01_;

}
}

// for data point Number 2 to bound x[0]:
for (int k=1; k<=Ndata-1;k++){
for (int m=1; m<=Ndata-1;m++){
int ix0_= xx0_index(k,m);
x_l[ix0_] = lb_x02_;
x_u[ix0_] = ub_x02_;

}
}
// for data point Number 3 to bound x[0]:

for (int k=2; k<=Ndata;k++){
for (int m=2; m<=Ndata-2;m++){
int ix0_= xx0_index(k,m);
x_l[ix0_] = lb_x03_;
x_u[ix0_] = ub_x03_;

}
}
}


and I made the same for each data point to bound x[1].`

the routine gives only 2 bounds with lower and upper bounds to X[0] for data point number 1 and 2 and the other point for x[O] , as the 3 data points for x[1] did not consider as bounded variables by the compiler. How can I resolve this issue please?
1. Use code tags.
https://www.cplusplus.com/articles/jEywvCM9/

2. Post something that can be compiled.
http://sscce.org/

Ideally, a simple main with something like
1
2
3
4
5
int main ( ) {
   int testdata[] = { 1, 2, 3, 4, 5, 6 };
   int result = yourFunction(testdata);
   printf("Answer=%d\n", result );
}

Show us some example of input, and explain what your desired result should be.

Hi , Thank you for contribution,
The code is composed of many files and classes and I created a derived class from the base one to solve the problem. I want to creat in files.cpp many bounds for both variables x[0] and x[1]to lie on data point .
please I need your help because I am really time constrained.
Thank you,
> The code is composed of many files and classes and I created a derived
> class from the base one to solve the problem.
Even more reason for you to create a simplified version of the problem that you're able to understand and analyse.

Create a little side project that allows you to focus specifically and only on the problem you're looking at at the moment. Maybe you'll figure it out once you have a simple clear view of it. If not, you'll have something clear to post to the forum.

When it works (and you know why it works), then you can integrate it back into your main program.
Because I have a problem with many variables, I want to know how to lie especially x[0] and x[1] on bounds of data points, and I want the output to lie the variables which depend on data to print them only on x[0] and x[1] where the other variables are automatically printed from the end of x[1] to the end of variables for examples for three data point I want this sequence:
x[0]=
x[1]=
x[0]=
x[1]=
x[0]=
x[1]=
x[2]=
...
x[n]
@gadi01,
Not a single one of your 5 posts to date is remotely intelligible.

Why don't you post the original problem (or a link to it), not your obscure rendering of it.


This question is the similar to your other question: it doesn't seem to make any sense at all.

Can you post a fully worked example? Post actual data (numbers) for the input; what the math function is; what the expected output is (numbers)

If it is a school project post a link to the actual question.
yes It is a school project I have no link and I have to work by myself. Please I creat a function member void Parameters(int N,double b_x01, double ub_x01, double lb_x02, double ub_x02)
in the base class as proctected function by using

protected:
void Parameters(int N,double b_x01, double ub_x01, double lb_x02, double ub_x02);
};
then I creat I dervied class from the base one
derived class: base class
// I define the lb_x01, ub_x01, lb_x02, ub_x02 by assigning value
b_x01= value1;
ub_x01= valu2;
lb_x02= value3;
lb_x02 = value4;
};
I when I call void Parameters(int N,double b_x01, double ub_x01, double lb_x02, double ub_x02) in file.cpp by making
void base class::parameters(int N,double b_x01, double ub_x01, double lb_x02, double ub_x02)
the compiler does not give these values. How can I resolve this please? How can I creat an instance of derived class for a sepcified member(i.e, lb_x01?
Please I need your help to advance because I have no time
Thank you;
@gadi01,
With every new reply that you post the situation becomes ever more confused. Perhaps it is a language problem, but your statements make absolutely no sense at all.

Please just write down the ORIGINAL problem - nothing more, nothing less - NOT your interpretation of it.


Looks like the people at StackOverflow don't understand you either:
https://stackoverflow.com/questions/69142139/incremented-optimization-variables-depending-on-data
Last edited on
lastchance
Thank you for your contribution
I said that I want to minimize a function f(x[i], i<=N) subject to C constraintes and bounds on variables where x[0] and x[1] are depending on M data
for M=1 only one data , the function is subject to:
value01_min<x[0]<value01_max ,and value11_min<x[1]<value11_max
for M=2 two data, the function is subject to:
value01_min<x[0]<value01_max, and value02_min<x[0]<value02_max ;and value11_min<x[1]<value11_max , and value12_min<x[1]<value12_max
and so on
and there C constraints Cj_min <g(j<=C)<Cj_max

Last edited on
@gadi01,
For goodness' sake, just copy out THE ORIGINAL PROBLEM FROM YOUR TEACHER.

Things like
value01<x[0]<value01

are completely impossible, since you are asking for a value that is, simultaneously, both strictly greater than and strictly less than the same thing. (EDIT: I see that you've finally changed that.)

So far, your explanations have been complete nonsense and that is why you are getting no answers either from this site or from StackOverflow.
Last edited on
@lastchance
Thank you
I edit the comment I know that it is impossible but I just want to show that x[0] and x[1]
are bounded variables to data .
I mean that the variable x[0] is variable that must be optimized to minimize a function which in turn is a vector that depend on the number of data :x[0,i=0...data]
for example if I have 2 two data point and I want to optimize 10 variables, the variables from x[0] to x[9], then I want two sets for x[0] and x[1] respectively, so I have 4 variables and 6 other variables are not depended on data
@gadi01

just copy out THE ORIGINAL PROBLEM FROM YOUR TEACHER.


Please read.
What I have to add I need your help please
Registered users can post here. Sign in or register to post.