필터 지우기
필터 지우기

How to define objective for this optimization problem?

조회 수: 4 (최근 30일)
Barbab
Barbab 2021년 12월 9일
댓글: Alan Weiss 2021년 12월 9일
My objective is:
subject to:
where k and h are two given vectors of size N. For this objective I tried:
x = optimvar('x',1,2,3,'LowerBound',0)
x =
1×2×3 OptimizationVariable array with properties: Array-wide properties: Name: 'x' Type: 'continuous' IndexNames: {{} {} {}} Elementwise properties: LowerBound: [1×2×3 double] UpperBound: [1×2×3 double] See variables with show. See bounds with showbounds.
k = rand(100,1);
h = rand(100,1);
obj = sum((x(1) + x(2)/x(3) * (k.^(-x(3))-1) - h).^2,'all')
Error using optim.internal.problemdef.operator.PowerOperator
Exponent must be a finite real numeric scalar.

Error in optim.internal.problemdef.Power

Error in .^
What is the proper way to define the objective? What's the best solver?
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 12월 9일
You appear to be using Problem Based Optimization rather than Solver Based.
We do not know what your z(3) is, but the context of the error message hints it might be one of your optimization variables.
Barbab
Barbab 2021년 12월 9일
Sorry, I edited my question, the problem is not connected to the optimization variables:
x = optimvar('x',1,2,3,'LowerBound',0)
x =
1×2×3 OptimizationVariable array with properties: Array-wide properties: Name: 'x' Type: 'continuous' IndexNames: {{} {} {}} Elementwise properties: LowerBound: [1×2×3 double] UpperBound: [1×2×3 double] See variables with show. See bounds with showbounds.
k = rand(100,1);
h = rand(100,1);
obj = sum((x(1) + x(2)/x(3) * (k.^(-x(3))-1) - h).^2,'all')
Error using optim.internal.problemdef.operator.PowerOperator
Exponent must be a finite real numeric scalar.

Error in optim.internal.problemdef.Power

Error in .^

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 12월 9일
  • x and y represent optimization arrays of arbitrary size (usually the same size).
  • a is a scalar numeric constant.
Supported operations
  • Pointwise power x.^a
Look through that list and notice that a.^x is not one of the supported operations. You cannot use problem-based optimization to take a constant to a power that is an optimization variable.
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 12월 9일
That just might work.
Alan Weiss
Alan Weiss 2021년 12월 9일
Yes, indeed. See the Note on the page Walter linked.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by