Home 21090308 › Forums › Numerical Method › Optimization › Constrained Optimization
 This topic is empty.

AuthorPosts

October 9, 2014 at 4:47 pm #2817ogreyespMember
Hello,
Anyone can help me to understand how work the constraints in SuanShu library. I don’t understand how this example represents this constraint x>=1
* A less than constraint for constrained optimization.
105 */
106 public static final LessThanConstraints C2 = new GeneralLessThanConstraints(
107 new AbstractBivariateRealFunction() {
108 @Override
109 public double evaluate(double x, double y) {
110 return 1 – x; // x >= 1
111 }
112 });If a have the following constraint:
q1+q2+….+qn<=1 How I can implement this in the SuanShu library? Best regards, Oscar
 This topic was modified 5 months, 1 week ago by hessinemaaoui.
 This topic was modified 5 months, 1 week ago by hessinemaaoui.
October 10, 2014 at 3:52 am #2818hao.dingMemberHi,
q1+q2+…+qn<=1 is a linear constraints, you can construct such a linear constraint in SuanShu use the following codes: Matrix A = new DenseMatrix(1, n); for (int i = 1; i <= n; i++) { A.set(1, i, 1.); } //A = [1,1,...,1] Vector b = new DenseVector(1.); // b = [1] LinearLessThanConstraints less = new LinearLessThanConstraints(A, b);
October 10, 2014 at 5:00 am #2819hao.dingMemberIn the example you mentioned, it represents the constraint x>=1 because it evaluates 1x, and when the evaluation is smaller than 0, the constraint is satisfied.
Therefore when you want to construct a constraint Ax>=b, in the evaluation part you should return bAX.
 This reply was modified 5 months, 1 week ago by hessinemaaoui.
October 10, 2014 at 8:42 am #2821ogreyespMemberThanks you very much for your quickly response.
Best regards,
Oscar
October 14, 2014 at 6:04 pm #2824ogreyespMemberHello,
I’ have defined an objetive function (it has some complexity) and 4 linear constraints (they are very simple). So, I have put the following code, as same as the example that comes with the SuanShu library:
///
double gamma = 1e30;
double epsilon = 1e8;
int maxIterations = 200;PenaltyMethodMinimizer optim = new PenaltyMethodMinimizer(
PenaltyMethodMinimizer.DEFAULT_PENALTY_FUNCTION_FACTORY,
gamma,
new BFGSMinimizer(false, epsilon, maxIterations));IterativeMinimizer minimizer = optim.solve(problem);
Vector xmin = minimizer.search(new DenseVector(q));
//////////
The problem that i have is the following: The BFGSMinimizer never outs from the 1 iteration, i.e it still executing in the 1st iteration of the BFGS algorithm and does’nt stop. I printed the value of the defined objetive function each time that it is evaluated for BFGS and for example this is the continiusly stream that appears in the screen:
16079.194741736539
16079.194729964249
16079.194738279763
16079.194733421027
16079.194726798403
16079.194744902386
16079.194737157148
16079.19473454364
….
…..
….
…. an go on.Anyone have an idea of why the BFGS algorithm does not stop.
Best regards,
Oscar
October 15, 2014 at 4:18 am #2825hao.dingMemberHi,
It is hard to know the problem if the objective function, constraints and data are unknown. It would be helpful if you can provide them. From the information you provided currently, my guesses are:
BFGS method is not good when the starting points are far from optimal point. Because it moves very slow. You can try other optimization method first, and use the results as starting points for BFGS to refine the results.
Another possibility is that the starting point is a local minimum but not a global minimum. So BFGS cannot move away from the starting points. You may try other starting points.
October 17, 2014 at 12:03 pm #2877webmasterMemberOur site should allow uploading file types with extensions such as *.java, *.zip, *.docx, *.xlsx. Please try again.
 This reply was modified 5 months, 1 week ago by hessinemaaoui.
October 17, 2014 at 4:08 pm #2879ogreyespMemberTrying…..
October 17, 2014 at 4:08 pm #2883ogreyespMemberThe codes were uploaded
October 20, 2014 at 5:06 am #2896hao.dingMemberHi,
I took a look at your constraint program, and found that your first, second and fourth constraints are same.
First constraint: sum(q)<=batch Second constraint: sum(q)<= d.size/2 (although you loop i from 1 to split point, but sum is sum(d)) Fourth constraint: sum(q)<=d.size Would you please let me know if I understand your constraints correctly? Also may I have your data and the program where you call QuasiNewtonOptimizer so I can debug your problem? Thanks. This reply was modified 5 months, 1 week ago by hessinemaaoui.
 This reply was modified 5 months, 1 week ago by hessinemaaoui.
October 20, 2014 at 7:38 am #2901ogreyespMemberHi Hao Ding.
Thanks you soo much for your help. I have restricted the problem only to the first and third constraint and the issue was resolved. You are right, the first, second and fourth constraint express the same.
Although, the BFGS method still runs ver slow, maybe due to the complexity of the objetive function. I will follow your past recomendation “try other optimization method first, and use the results as starting points for BFGS to refine the results.”
Again, thanks very much for your help.
Best regards,
Oscar

AuthorPosts
 You must be logged in to reply to this topic.