Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Setting up simple optimization problem

Please login with a confirmed email address before reporting spam

Hi all, i have some doubts about setting the optimization module.
My aim is quite simple, i should find the optimal value of a variable to minimize the objective equations.
In particular i should set up the parameter C in this equation(which represents the outlet pressure of a laminar flow model):

S=Q*C+po

in order to minimize the following equation:

abs(p-15000)

Where p is the pressure coming out from linear flow model (spf) and 15000 is a reference pressure, both applied to domain.
The algorithm is quite simple, comsol should:

1)assign a value to C
2)estimate the value of domain pressure( coming out from laminar flow model)
3)verify if optimality condition is satisfied, otherwise start again from 1

My doubt is about implementation: which kind of objective should i use (integral objective, probe objective...)? Should i use inequality constraints too?

Best regards

5 Replies Last Post May 14, 2012, 7:14 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 6, 2012, 11:07 p.m. EDT
Your objective function would perhaps be better set up as:
(p-15000)^2
which may give a more rapid convergence than your linear formulation.

How you set up your objective function depends on how you will evaluate p. If p is defined on a point, you could use a point objective. If not, you could set up a probe to calculate the average of p over a boundary, and use this in a global objective, replacing 'p' with the probe name.

You would also add a global control variable and specify C. You will need to give an appropriate initial value so that the local minimum objective found is the correct one. If you need to add constraints on C, you can also do this, but since you have only one control variable, this may not be necessary with a good initial guess.
Your objective function would perhaps be better set up as: (p-15000)^2 which may give a more rapid convergence than your linear formulation. How you set up your objective function depends on how you will evaluate p. If p is defined on a point, you could use a point objective. If not, you could set up a probe to calculate the average of p over a boundary, and use this in a global objective, replacing 'p' with the probe name. You would also add a global control variable and specify C. You will need to give an appropriate initial value so that the local minimum objective found is the correct one. If you need to add constraints on C, you can also do this, but since you have only one control variable, this may not be necessary with a good initial guess.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 8, 2012, 6:51 a.m. EDT
Thank you very much for your answer, i found it very useful. I forgot to specify that my model is 3D and p is the average pressure over the domain (my model is a simple cilinder, so there is only one domain); so i setted up a probe to calculate the average of p over the domain (named by comsol "dom2") and setted optimization module this way:

Global Objective: (dom2-15000)^2
Control variable Field : C with an initial value of 1.4e8 (opplied only to outlet boundary)
Pointwise inequality constraint: C with lower bound=1.4e8 and higher bound=2.666e8

I used that values for C because i found on a paper that they should vary from 1.4e8 to 2.666e8, so the optimal value should be between these.
However i think that i should change some setting to consider the hugeness of C values:
infact, as you can see from the attached image, the variations in C value each iteration is too low, so COMSOL returns only a few of results and then stops saying that the current point can't be improved.

LOG:
Optimization Solver 1 in Solver 1 started at 8-mag-2012 11:59:05.
Optimization solver (SNOPT)
Itns Major Minor Step nPDE Error Objective
416 0 416 - 1 0.00115 7.435e+006
516 1 100 0.11 2 0.00115 7.435e+006
616 2 100 0.07 4 0.00115 7.435e+006
716 3 100 1.00 5 0.00115 7.435e+006
Warning: There were 8 warning messages from the linear solver.
Warning: Ill-conditioned preconditioner. Increase factor in error estimate.
Warning: Forward solution failed, requesting reduced step.
Warning: There were 61 warning messages from the linear solver.
Warning: Ill-conditioned preconditioner. Increase factor in error estimate.

then i canceled the process.

Should i increase the C value increase at each iterations?
Thank you very much for your answer, i found it very useful. I forgot to specify that my model is 3D and p is the average pressure over the domain (my model is a simple cilinder, so there is only one domain); so i setted up a probe to calculate the average of p over the domain (named by comsol "dom2") and setted optimization module this way: Global Objective: (dom2-15000)^2 Control variable Field : C with an initial value of 1.4e8 (opplied only to outlet boundary) Pointwise inequality constraint: C with lower bound=1.4e8 and higher bound=2.666e8 I used that values for C because i found on a paper that they should vary from 1.4e8 to 2.666e8, so the optimal value should be between these. However i think that i should change some setting to consider the hugeness of C values: infact, as you can see from the attached image, the variations in C value each iteration is too low, so COMSOL returns only a few of results and then stops saying that the current point can't be improved. LOG: Optimization Solver 1 in Solver 1 started at 8-mag-2012 11:59:05. Optimization solver (SNOPT) Itns Major Minor Step nPDE Error Objective 416 0 416 - 1 0.00115 7.435e+006 516 1 100 0.11 2 0.00115 7.435e+006 616 2 100 0.07 4 0.00115 7.435e+006 716 3 100 1.00 5 0.00115 7.435e+006 Warning: There were 8 warning messages from the linear solver. Warning: Ill-conditioned preconditioner. Increase factor in error estimate. Warning: Forward solution failed, requesting reduced step. Warning: There were 61 warning messages from the linear solver. Warning: Ill-conditioned preconditioner. Increase factor in error estimate. then i canceled the process. Should i increase the C value increase at each iterations?


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 8, 2012, 8:14 a.m. EDT
Hi

often before you start an optimisation, then it's worth to prescan the domain (in particular when you have only 1 variable) i.e. run a continuation scan or parametric sweep of your variable and then start your optimisation close to the final value

--
Good luck
Ivar
Hi often before you start an optimisation, then it's worth to prescan the domain (in particular when you have only 1 variable) i.e. run a continuation scan or parametric sweep of your variable and then start your optimisation close to the final value -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 8, 2012, 1:03 p.m. EDT
Marco,

The ill-conditioned preconditioner warning suggests that your model is not well formulated. As Ivar suggested, try running a parametric sweep on several values of C across your inequality range to make sure the model solves properly. This will need to be fixed first.

Other comments:

I see you have variables C1 as well as C. What is the purpose of C1? You should optimize C directly if C is the parameter in your equation. This may contribute to the lack of progression in your optimization.

I see you have defined a Control Variable Field for C. This should be a Global Control Variable defined as C.

You have defined a pointwise inequality constraint on C1. This perhaps should be a global inequality constraint (again, on C rather than C1). With C defined as a Global Control Variable however, you can provide the upper and lower bounds in that dialog box, eliminating the need for this additional constraint.

Your model is stuck with a pressure of 12947, which is a distance away from your target of 15000. Using the parametric solver, make sure there is not a local minimum near that value of C. Given the form of your equation, I suspect this is not the problem, and reformulation of your model as described above may take care of this.

If these do not solve the problem, send a copy of your model. However, I will not have access to my COMSOL workstation for the next 2 weeks.
Marco, The ill-conditioned preconditioner warning suggests that your model is not well formulated. As Ivar suggested, try running a parametric sweep on several values of C across your inequality range to make sure the model solves properly. This will need to be fixed first. Other comments: I see you have variables C1 as well as C. What is the purpose of C1? You should optimize C directly if C is the parameter in your equation. This may contribute to the lack of progression in your optimization. I see you have defined a Control Variable Field for C. This should be a Global Control Variable defined as C. You have defined a pointwise inequality constraint on C1. This perhaps should be a global inequality constraint (again, on C rather than C1). With C defined as a Global Control Variable however, you can provide the upper and lower bounds in that dialog box, eliminating the need for this additional constraint. Your model is stuck with a pressure of 12947, which is a distance away from your target of 15000. Using the parametric solver, make sure there is not a local minimum near that value of C. Given the form of your equation, I suspect this is not the problem, and reformulation of your model as described above may take care of this. If these do not solve the problem, send a copy of your model. However, I will not have access to my COMSOL workstation for the next 2 weeks.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 14, 2012, 7:14 a.m. EDT
Tahk you very very vey much! Now the optimization works! I followed Ivar'suggestion and i did a prescan using parametric sweep. The i followed Steve'suggestion using global objective and global control variable.
Finally i obtained the results i expected.

Thank you again for your precious suggestion and your great hlpfulness.

Best regards,
Marco
Tahk you very very vey much! Now the optimization works! I followed Ivar'suggestion and i did a prescan using parametric sweep. The i followed Steve'suggestion using global objective and global control variable. Finally i obtained the results i expected. Thank you again for your precious suggestion and your great hlpfulness. Best regards, Marco

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.