Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

TARGETVALUE OPTIMIZATION??

Status
Not open for further replies.

bakoriua

Aerospace
Jun 29, 2005
3
IT
I'm traing to run an optimization with target value,
but I Have always this error : "the method targetvalue failed"

Does anyone know why?

Dim oActiveDoc As Document
Set oActiveDoc = CATIA.ActiveDocument

' Check whether the document is a CATPart
If (InStr(oActiveDoc.Name, ".CATPart")) <> 0 Then

' Retrieve the collection object which contains
' all the document relations.
' The statements below are only valid when the active
' document is a CATPart
Dim oRelations As Relations
Set oRelations = oActiveDoc.Part.Relations

' Retrieve the collection object which contains
' all the document parameters.
Dim oParameters As Parameters
Set oParameters = oActiveDoc.Part.Parameters

' Create Real type parameter as objective to be optimized.
Dim oFx As Parameter
Set oFx = oParameters.CreateReal("Real1", 199)
oFx.Rename "fx"

' Create Real type parameter as free parameter.
Dim oX As RealParam
Set oX = oParameters.CreateReal("Real2", 299)
oX.Rename "x"

' Create a formula to be optimized.
Dim oFormula As Formula
Set oFormula = oRelations.CreateFormula("Objective", "This is the objective function.", oFx, "x*x + 8.0")

' Retrieve the collection object which contains
' all the document optimizations.
Dim oOptimizations As Optimizations
Set oOptimizations = oRelations.Optimizations

' Create the optimization feature.
Dim oOptimization1 As Object
Set oOptimization1 = oOptimizations.CreateOptimization()
oOptimization1.OptimizationType = catTargetValue
oOptimization1.AlgorithmType = catSimulatedAnnealing


'Set up the optimization feature attributes.
oOptimization1.MaxEvalsNb = 300
oOptimization1.UseMaxTime = True
oOptimization1.MaxTime = 2 '2 minutes.
oOptimization1.UseMaxEvalsWoImprovement = True
oOptimization1.MaxEvalsWoImprovement = 200
Dim otar As RealParam
Set otar = oParameters.CreateReal("tar", 999)
oOptimization1.TargetValue = otar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top